我正在使用 Tablesorter 来显示一个表格,并且我有一列带有一个带有多个选项的下拉过滤器。像这样:
widgetOptions : {
filter_functions: {
4: {
users_all : function() {},
users_collaborators : function() {},
users_clients : function() {}
}
}
}
所有这三个值(users_all、users_collaborators 和 users_clients)都是变量,但它们显示为字符串。
有什么方法可以显示变量的内容吗?
更新 1
我想做的是用一种或另一种语言显示选项(与表格无关)。
我试过像这样通过 filter_selectSource 更改选择选项:
widgetOptions: {
filter_selectSource: {
4 : [ 'Client', 'Collaborator' ]
},
filter_functions: {
4 : true
}
}
但它在 jquery.tablesorter.widgets.js:1464 上抛出错误(无法读取未定义的属性“格式”)
我正在通过 ajaxProcessing 填充表格,并且我正在像其他任何过滤器一样选择这个过滤器:
ajaxUrl: '/users/table_users.php?page={page}&size={size}&{sortList:sort}&{filterList:filter}'
我尝试自己设置您的演示,完全没有问题。
一旦解决它看起来像:
widgetOptions : {
filter_functions: {
4: true
},
filter_selectSource: {
4 : [ user_all, user_collaborators, user_clients ]
}
}
我已将类 filter-select-nosort
添加到表中该列的标题中。
最佳答案
您到底想用过滤器选择做什么?
您可以使用 filter_selectSource
option 更改选择选项( demo )
$(function () {
$('table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_selectSource: {
1 : [ 'Client', 'Collaborator' ]
}
}
});
});
关于javascript - 在 Tablesorter 中,为列过滤器的下拉选项设置不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28899512/