Table sorter filter for each column

大憨熊 提交于 2019-12-02 08:24:33

If you aren't using the pager widget, then you can bind to the filterStart event. But make sure to add a method to not make another ajax call because the filterStart event will fire again after the table updates. Try something like this (this is untested code):

var $table = $('table');

$table
    .on('filterBegin', function( event, filters ){
        // only trigger an ajax call if the filters have changed
        if ( filters.join(',') !== $table.data('lastSearch').join(',')  ) {
            // do some ajax stuff here
            // then in the success callback, save content to table...
            // then update
            $table
                .find('tbody')
                .html( newContent )
                .trigger('update');
        }
    })
    .tablesorter({
        // add your other options here
        widgetOptions: {
            // you might need to set this option to prevent
            // rows from being hidden... maybe!
            filter_serversideFiltering : true
        },
        initialized: function(){
            lastSearch = $table.data('lastSearch');
        }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!