[英]Use variable from DataTables ajax response to populate yadcf filter
I have a DataTables table defined like this:我有一个像这样定义的 DataTables 表:
$(function () {
var yadcf_data_3;
var oTable = $('#example').DataTable({
"serverSide": true,
"ajax": {"url": "/platform/elements/?format=datatables",
"dataSrc": function(json){
yadcf_data_3 = json.options.yadcf_data_3
//this line returns the appropriate list of values
console.log(yadcf_data_3)
return json.data;
}
}
});
//this line returns undefined
console.log(yadcf_data_3)
//other stuff
yadcf.exRefreshColumnFilterWithDataProp(oTable, 3, yadcf_data_3);
});
How do I use yadcf_data_3
to populate a filter for the table?如何使用yadcf_data_3
填充表的过滤器? yadcf_data_3
returns undefined outside of the oTable
variable. yadcf_data_3
在oTable
变量之外返回 undefined 。
var table = $("#employeetable").DataTable({
"ajax": {
"url": "/url",
"type": "POST",
"datatype": "json"
, dataSrc: function (data) {
CalculateSum= data.CalculateSum;
return data.data;
}
}
....
drawCallback: function (settings) {
var api = this.api();
$('#CalculateSum').html(CalculateSum);
},
"serverSide": "true",
"order": [0, "desc"],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.