Search code examples
c#jqueryasp.nettablesorter

Disable ascending/descending order in jquery tablesorter only for initial page load


I created mvc 4 application , in this application I'm listing down a table

this is view of it

enter image description here

Each time its listing down ascending order , according to first column value

this is jquery code snippet

        $(function () {
        $("#table-hover").tablesorter({ widthFixed: true, sortList: [[0, 0]] })
        .tablesorterPager({ container: $("#pager"), size: $(".pagesize option:selected").val() });
    }); 

I want to disable this ascending/descending feature and keep remain pagination of jquery tablesorter plugin in initial page load


Solution

  • If you only need pagination, then you really don't need to use tablesorter. I'm sure asp.net provides a method to add it.

    In any case, since you appear to be using the original tablesorter, you could disable every column to prevent sorting as @oMiKey suggests. If you use my fork of tablesorter, simply add "sorter-false" to each header cell.

    To prevent the initial sort, remove the sortList: [[0, 0]] option from the initialization code:

    $(function () {
        $("#table-hover")
            .tablesorter({
                widthFixed: true
            })
            .tablesorterPager({
                container: $("#pager"),
                size: $(".pagesize option:selected").val()
            });
    });