Home > Work > #SP2010 Group List Items by External Data field–Field Display Missing #in

#SP2010 Group List Items by External Data field–Field Display Missing #in

On an intranet I have been working on recently I came across a bug where the display of an External Data field in the 1st and 2nd level grouping is not shown when grouping by the BCS based item(s).

To provide a short term fix I created the following JavaScript to run on the page to solve the problem.

1 <script type="text/javascript"> 2 3 _spBodyOnLoadFunctionNames.push("updateGroupNameValues_Level1"); 4 5 function updateGroupNameValues_Level1() 6 { 7 $('TBODY[id*=titl]').each(function() 8 { 9 var currentGroupString = unescapeProperly(($(this).attr("groupstring"))); 10 currentGroupString = currentGroupString.replace(';', ''); 11 var groupStringArray = currentGroupString.split("#"); 12 var groupLevel1 = groupStringArray[1]; 13 var groupLevel2 = groupStringArray[2]; 14 15 var currentSpan = $(this).find("span").text(); 16 var newSpan; 17 if (groupLevel2 == "") 18 { 19 newSpan = groupLevel1 + " " + currentSpan; 20 $(this).find("span").text(newSpan); 21 22 } 23 else 24 { 25 newSpan = groupLevel2 + " " + currentSpan; 26 $(this).find("span").text(newSpan); 27 } 28 29 //alert("groupLevel1: " + groupLevel1 + " | groupLevel2: " + groupLevel2); 30 //alert(($(this).children("span").html())); 31 }); 32 } 33 34 </script> 35

Essentially the values do exist in the DOM / HTML, but they are not displayed in the tags presented by the grouping.

NB: Please be aware that this solution relies upon JQuery.

Advertisements
  1. Alberto
    March 5, 2012 at 14:19

    Thank you. Your solution seems to me could be better supported then one suggested in http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/a73896a4-43b4-474e-8fb1-c8a7ccf7056f/

  2. s
    April 30, 2013 at 18:15

    this fixes the duplication of text when mixing BDC and non-BDC grouping:

    function updateGroupNameValues_Level1()
    {
    $(‘TBODY[id*=titl]’).each(function()
    {
    var currentGroupString = unescapeProperly(($(this).attr(“groupstring”)));
    currentGroupString = currentGroupString.replace(‘;’, ”);
    var groupStringArray = currentGroupString.split(“#”);
    var groupLevel1 = groupStringArray[1].replace(‘;’, ”);
    var groupLevel2 = groupStringArray[2].replace(‘;’, ”);

    var currentSpan = $(this).find(“span”).text();
    var newSpan;
    if (groupLevel2 == “”)
    {
    newSpan = groupLevel1 + ” ” + currentSpan;
    $(this).find(“span”).text(newSpan);
    var tdtext = $(this).find(“td”).text().replace(groupLevel1 + groupLevel1,groupLevel1);
    $(this).find(“td”).text(tdtext);

    }
    else
    {
    newSpan = groupLevel2 + ” ” + currentSpan;
    $(this).find(“span”).text(newSpan);
    var tdtext = $(this).find(“td”).text().replace(groupLevel2 + groupLevel2,groupLevel2);
    $(this).find(“td”).text(tdtext);
    }

    //alert(“groupLevel1: ” + groupLevel1 + ” | groupLevel2: ” + groupLevel2);
    //alert(($(this).children(“span”).html()));
    });
    }

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: