1

I am showing the database table using tableSorter jquery plugin. I have large number of records so I have to paginate. If there is only one page of data, I can allow tablesorter to do client sorting, however, when I have more pages I need to specify sorting order using ORDER BY sql statement so that all pages are affected.

I tried using startSort event without much success. First I modified tableSorter code to get as an argument sortList. Then I was using ajax call inside startSort event to call MVC handler that is parsing sortList array to construct valid sql ordering. I was also experiencing problems with event not being fired (when I specify multiple sort columns using shift) or event triggering 2 times.

Does anybody knows some plugin or knows a way to implement this ?

Short code snippet of stuff I tried looks like this;

function OnAjaxSuccess() {


     SortList = typeof SortList == "undefined" ? [] : SortList
     $("table").tablesorter
        ({
            ...
     sortList = SortList
        });

     $("table").bind("sortStart", function(event, newSortList) 
                         {   
                            if (PageCount = 1) return;
                            SortList = newSortList; 
                            var url = '/Report/Sort/' + SortList.toString();   
                            $("#Report").load(url, null, OnAjaxSuccess );                            
                         })

Thanks.

1 Answer 1

1

You can use the plugin http://www.datatables.net/, pretty light, can paginate and it can be connected directly to the database with the right server side processing.

3
  • I want to like that plugin, really I do. However, when they say "a single function call to initialise the table is all it takes" and the example on the very same page has an array of configuration elements, they get a thumbs down from me.
    – Powerlord
    Mar 29, 2010 at 14:24
  • You didn't look at correct sample. See "zero configuration" page which works that way.
    – majkinetor
    Mar 29, 2010 at 17:14
  • $('#example').dataTable( { "bJQueryUI": true, "sPaginationType": "full_numbers" } ); These configuration elements are optional, it might not be the most clever thing to put them on the home page, but still.
    – rnaud
    Mar 29, 2010 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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