Please add Unicode DisplayName support

Apr 5, 2010 at 9:41 AM
Edited Apr 5, 2010 at 9:43 AM

Hi Marc, 

 

Thanks for a fabulous framework, it's great for Latin-based languages, but please add support for non-Latin DisplayNames too. The control is found by whichever display name you have, but I've found that putting DisplayName in element ID fails in IE 8 and referencing thereby is impossible. Can you fix that?

 

Thanks again.

Apr 5, 2010 at 11:40 AM
Edited Apr 5, 2010 at 3:43 PM

 

        var indexOfDN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("FieldName=\""+opt.columnName+"\"");
        var staticNameFIN = "";
        if (indexOfDN >0 )
        {
            var indexOfFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("FieldInternalName=\"");
            var offsetFIN = "FieldInternalName=\"".length;
            var endOfFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("\"", indexOfFIN+offsetFIN+1);
                staticNameFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.substring(indexOfFIN+offsetFIN,endOfFIN);
        }
        else 
        {return Error();}
        var indexOfDN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("FieldName=\""+opt.columnName+"\"");
        var staticNameFIN = "";
        if (indexOfDN >0 )
        {
            var indexOfFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("FieldInternalName=\"");
            var offsetFIN = "FieldInternalName=\"".length;
            var endOfFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.indexOf("\"", indexOfFIN+offsetFIN+1);
                staticNameFIN = $(columnSelect.Obj).parents("TD")[0].children[0].nodeValue.substring(indexOfFIN+offsetFIN,endOfFIN);
        }
        else 
        {return Error();}

instead of simply encoding spaces with

 

    function encodeColumn(s) {
        return s.replace(/ /g, '_x0020_');
    }

 

 

Hope this could be useful

 

Coordinator
Apr 5, 2010 at 1:55 PM

ACrush:

Can you give me some examples where the code as it stands isn't working?  Perhaps show me some of the source markup?

I've made several adjustments already for non-English langauage packs, but perhaps there are a few more required.  Because I can't possibly test with all of the language packs, I've been trying to put in fixes onm a case by case basis, generalizing for as many possibilities as seem to make sense.

Thanks,
M.

Apr 5, 2010 at 3:44 PM

just try naming the SPLookup field something like "Поле" rather than "Field". You will see the difference.

Coordinator
Apr 5, 2010 at 3:48 PM

Right, but I really need to see some markup to know how to fix it.  Can you post some examples?

Thanks,
M.

Apr 5, 2010 at 3:57 PM

 

Here's how I see the key fragment (changed values a bit)
<TD class=ms-formbody vAlign=top width=400><!-- FieldName="Изготовитель"
			 FieldInternalName="Vendor"
			 FieldType="SPFieldLookup"
		  --><SPAN dir=none><SELECT id=ctl00_m_g_750bcf13_2293_47ba_a201_e26f24680b48_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup title=Изготовитель name=ctl00$m$g_750bcf13_2293_47ba_a201_e26f24680b48$ctl00$ctl04$ctl02$ctl00$ctl00$ctl04$ctl00$Lookup> <OPTION value=0>(нет)</OPTION> <OPTION value=6>AirBus Industries</OPTION> <OPTION value=4>Boeing Industries</OPTION> <OPTION value=7>Cessna</OPTION> <OPTION value=5>McDonnell Douglas</OPTION> <OPTION value=14>LAX</OPTION> <OPTION value=15>SVO</OPTION> <OPTION value=13>ORL</OPTION> <OPTION value=11>NYK</OPTION> <OPTION value=8>MI-5</OPTION> <OPTION value=10>London HQ</OPTION> <OPTION value=12>Shanghai Residency</OPTION> <OPTION value=2>Aston Martin</OPTION> <OPTION value=1>Lotus</OPTION> <OPTION value=9>CIA</OPTION> <OPTION selected value=3>KGB</OPTION></SELECT><BR></SPAN></TD>

SPServices tries to construct the div_Id variable using FieldName rather than FieldInternalName successfully assigns the ID of "selectCtl_Изготовитель" (or something) but later on fails to handle it when building the RelatedInfo table.

 

Apr 5, 2010 at 3:59 PM

I'm sure jPoint already has the code to handle FieldName to FieldInternalName mapping using these comments automatically included by SharePoint form generator. On the other hand, you could use another WS-roundtrip to do so.

Coordinator
Apr 5, 2010 at 4:00 PM

Which function are you having problems with?

M.

Apr 5, 2010 at 4:02 PM

showRelated()

Coordinator
Apr 5, 2010 at 4:06 PM

This is a little tough to decipher.  So you're having an issue with SPDisplayRelatedInfo, right?  I'm not relying on the FieldName in the comments in that function, so I'm not sure what issue you might be having.

M.

Apr 5, 2010 at 4:07 PM

 

        var divId = "showRelated_" + encodeColumn(opt.columnName);
        $("#" + divId).remove();
        columnSelect.Obj.parent().append("");

...


                            $("#showRelated_" + encodeColumn(opt.columnName)).html("").append(outString);


...


                        $("#showRelated_" + encodeColumn(opt.columnName)).html("").append(outString);


...

    // Encode a column name
    function encodeColumn(s) {
        return s.replace(/ /g, '_x0020_');
    }

I think it would make perfect sense to build a function that does the opposite of SPGetDisplayFromStatic -> SPGetStaticFromDisplay

 

Apr 5, 2010 at 4:21 PM
Edited Apr 5, 2010 at 4:24 PM

FieldName is equivalent to opt.columnName which requires a DisplayName which could contain commas as well as spaces, and those should be encoded too.

I don't want to push you to use these comments. The point is that $("#showRelated_Изготовитель") seems to return something like 'undefined'. I may be mistaken here - it's just a good  guess I cannot confirm right now.

I beleive my brief debugging session hinted at outString building correctly but not being written to the target location.

("#showRelated_" + encodeColumn(opt.columnName))
Coordinator
Apr 5, 2010 at 4:21 PM

I'm still not seeing what the actual issue is.  So we end up with an ID that looks like 'showRelated_Изготовитель'. Again, what is the issue?

M.

Apr 5, 2010 at 4:26 PM

As always: failure to meet expectations. Related Info is displayed only if I rename the field in the list into somthing like "Vendor Title" (this works). If I rename the field into "The truth, actually" it fails to render the related info as expected.

Coordinator
Apr 5, 2010 at 4:29 PM

Ah, OK. Now that is a specific!  Yes, I should be encoding all characters or using the InternalName to handle that.

M.

Apr 5, 2010 at 4:31 PM

Mapping DisplayName (convenient for end users) to InternalName (reliable), I think. The choice is yours ;-)

Apr 5, 2010 at 4:37 PM

Just to remind you the obvious argument, some languages use two-byte extended codepages that generate scary InternalNames like _x041f__x041f__x0397__.....__x04_2 and only use few leading characters of the DisplayName to generate that.

Coordinator
Apr 5, 2010 at 4:47 PM

Your point is absolutely valid. My only hesitation is that it would change the ID and anyone who has written code which relies on the existing structure will have that code break.  I think that the number of people that might affect will be minimal, however.

Since I will be making a change, I'll make it consistent with the IDs I'm creating in other functions (e.g., SPLookupAddNew) and go with:

'SPDisplayRelatedInfo_' + [the column's StaticName]

Make sense?

M.

Apr 5, 2010 at 4:50 PM

Yep. Perfectly for me.

Coordinator
Apr 5, 2010 at 4:54 PM
Edited Apr 5, 2010 at 4:55 PM

Sorry for missing your point initially and thanks for the suggestion!

I'm going to put this into v0.5.4ALPHA5, which I'll probably post later today.  I'll also add the reverse function, as you suggested:

$().SPServices.SPGetStaticFromDisplay

M.

Coordinator
Apr 5, 2010 at 4:56 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.