0

We have just migrated our site from SP2010 to SP2013 where we have used DataFormWebPart in many pages. But after migration the sorting is not working properly on those pages.

Sorting only works when we click on column title. If we click on small arrow icon near header title and select either 'Ascending' or 'Descending', its not working from context menu.
It used to work earlier in SP 2010

Here is screenshot of the same.
enter image description here


Update
Same is observed when I create new DataFormWebPart in SharePoint 2013. Does anyone encountered this problem earlier ? IS this a bug in SharePoint 2013 ?

  • Facing the same problem here. Please let us know in case you find any work around. – Rohit Waghela Mar 28 '16 at 9:54
0

As I didn't got any perfect solution, I am posting down a fix which I made with the help of jQuery.

$(document).ready(function(){
    $("th.ms-vh > table").click(function(){
        var intervalID = setInterval(startCheck, 500); // >>> on table header(column) click, execute startCheck function continously(every 0.5 second)
        setTimeout(function(){clearInterval(intervalID);}, 5000); // >> stop execution after 5 seconds
    });
});

function startCheck(){
    if( $("li.ms-core-menu-item[text='Descending'][type='option']").length > 0 ){ // >>> Check if context menu is loaded            

        // >>> get onclick script from <li>
        var desScript = $("li.ms-core-menu-item[text='Descending'][type='option']").attr("onmenuclick").toString().replace("descending","'descending'"); 
        var ascScript = $("li.ms-core-menu-item[text='Ascending'][type='option']").attr("onmenuclick").toString().replace("ascending","'ascending'");

        // >>> set onclick and href attribute of <a> tags for Ascending and Descending menu options
        $("li.ms-core-menu-item[text='Descending'] > a").attr("href", desScript);
        $("li.ms-core-menu-item[text='Ascending'] > a").attr("href", ascScript);

        $("li.ms-core-menu-item[text='Descending'] > a")[0].setAttribute('onclick',desScript);
        $("li.ms-core-menu-item[text='Ascending'] > a")[0].setAttribute("onclick", ascScript);

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.