I have a column in a dataTable that I want to filter.
(我在dataTable中有一列想要过滤。)
I can filter by columns which are defined like this: (我可以按定义如下的列进行过滤:)
"columns": [
{
"data": function (data) {
return data['columnToFilter'];
}
},
];
But, I can't find a way to filter columns which are more than the original value, such as this one:
(但是,我找不到一种方法来过滤超出原始值的列,例如:)
"columns": [
{
"data": function (data) {
return '<h1>' + data['columnToFilter'] + '</h1>';
}
}
];
How can I tell dataTables what raw the value (without the html) of the second column is?
(我怎样才能告诉dataTables第二列的原始值是什么(不含html)?)
Here is my code that does the filtering:
(这是我执行过滤的代码:)
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
// tabLocation can only be filtered if the value is returned without additional html
var tabLocation = data[0];
if ($("#myFilter").hasClass("down")) {
return true;
} else {
if (tabLocation == 0) {
return true;
}
}
}
);
$.fn.toggleText = function(t1, t2){
if (this.text() == t1) this.text(t2);
else this.text(t1);
return this;
};
ask by user783322 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…