我有两个标签,每个标签都包含一个数据表。 我想在两个表上设置列过滤器。我的代码是:
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link rel="stylesheet"
href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
</head>
<body>
<p>toast-top-center</p>
<button onclick="myFunction()">Click Here</button>
<p id="demo"></p>
<script>
function myFunction() {
toastr.options = {
"positionClass" : "toast-top-center",
"closeButton" : false,
"debug" : false,
"newestOnTop" : false,
"progressBar" : false,
"preventDuplicates" : false,
"onclick" : null,
"showDuration" : "300",
"hideDuration" : "1000",
"timeOut" : "5000",
"extendedTimeOut" : "1000",
"showEasing" : "swing",
"hideEasing" : "linear",
"showMethod" : "fadeIn",
"hideMethod" : "fadeOut"
}
Command: toastr["success"]
("I'm in the top-center!")
}
</script>
</body>
</html>
//
$(function() {
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"date-euro-pre": function (a) {
if ($.trim(a) != '') {
var frDatea = $.trim(a).split(' ');
var frTimea = frDatea[1].split(':');
var frDatea2 = frDatea[0].split('/');
var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;
} else {
var x = 10000000000000; // = l'an 1000 ...
}
return x;
},
"date-euro-asc": function (a, b) {
return a - b;
},
"date-euro-desc": function (a, b) {
return b - a;
}
});
});
$(function() {
$("#completed").dataTable({
"bSort": false,
"aoColumns": [
null,
null,
{ "sType": "date-euro" },
null,
null,
null,null,
null
],
"aaSorting": [[2, 'desc']]
}).columnFilter({
aoColumns: [
null,
{type: "select", values: ['SENT PAYMENT', 'RECEIVED PAYMENT', 'SENT REQUEST', 'RECEIVED REQUEST', 'RECHARGE', 'BILLPAY', 'PAYMENT MISSED']},
null,
{type:"select", values: ['WALLET','ACCOUNT']},
{type:"select", values:['COMPLETED','ERRORED']},
null,
null,
null
]
});
var b= $("#pending").dataTable({
"bSort": false,
"aoColumns": [
null,
null,
{"sType": "date-euro"},
null,
null,
null, null,
null
],
"aaSorting": [[2, 'desc']]
}).columnFilter({
aoColumns: [
null,
{
type: "select",
values: ['SENT PAYMENT', 'RECEIVED PAYMENT', 'SENT REQUEST', 'RECEIVED REQUEST', 'RECHARGE', 'BILLPAY', 'PAYMENT MISSED']
},
null,
{type: "select", values: ['WALLET', 'ACCOUNT']},
null,
null,
null,
null
]
})
现在的问题是,它只将过滤器设置为最后一个表,即id为“pending”的表。任何人都可以帮我解决这个问题吗?