2012-10-25 66 views
-1

我想在html表格中筛选和排序选项。我试过'tablesorter.js',在tablesorter.js中添加下拉列表

我可以使用这个模块对表格字段进行排序。但我不能添加下拉列表和过滤框与表字段。

任何人都可以帮助我?

+0

显示你的代码!问题出在哪里? –

+0

请告诉我如何在tablesorter.js中添加下拉列表和过滤器http://tablesorter.com/docs/#Demo现在我的应用程序可以像这样工作 – Anoop

+0

我想在字段中添加下拉列表和过滤器框。 – Anoop

回答

1

尝试使用 This.

这是短的HTML表格。

OR

(DEMO)短期使用下拉列表

$('table').tablesorter(); 

$('select').change(function(){ 
    var column = parseInt($(this).val(), 10), 
     direction = 1, // 0 = descending, 1 = ascending 
     sort = [[ column, direction ]]; 
    if (column >= 0) { 
     $('table').trigger("sorton", [sort]); 
    } 
}); 
+0

我试过了。我想添加下拉列表和过滤框的字段。 – Anoop

+0

你知道任何其他模块做同样的事情? – Anoop

+0

@ user1077645 ..请参阅编辑答案 –

0

您可以通过添加类=“过滤器选择”以添加一个下拉列表过滤表中的列在那个专栏里。

<thead><th>Col 1></th><th class="filter-select">Col2</th></thead> 

或者你可以为列添加过滤功能:

filter_functions : { 

    // Add select menu to 3rd column (column numbers are zero-based). 
    // Set the column value to true, and/or add "filter-select" class name to header 
    2 : true, 
}