我有一个正在渲染的数据表,其中填充了来自 ajax 调用的数据,这是用于此的代码:
let table;
table = $('#table_preview').DataTable({
"pageLength": 10,
"processing": true,
"ajax": {
"url": '/assets/ajax/table_ajax_handler.php',
"type": "POST",
"data": { action: "getPesticidesForTable" }
},
"columns": [
{ "data": "crop" },
{ "data": "diseases" },
{ "data": "chemical" },
{ "data": "product" },
{ "data": "rate" },
{ "data": "max_no" },
{ "data": "hi" },
{ "data": "mrl" },
{ "data": "pcs_no" },
{ "data": "supplier" }
]
});
$.ajax({
url: "/assets/ajax/table_ajax_handler.php",
type: "POST",
data: {
action: 'getPesticidesForTable'
}
})
.done(res => {
console.log(res);
});
我的问题是,是否有一种方法可以只显示“作物”为“小麦”的行,而无需手动搜索。显然,最终目标是使其动态化并根据用户点击或预先确定的内容进行过滤。我已经浏览了数据表文档,但似乎找不到任何内容
答案 0 :(得分:0)
经过更多挖掘,我找到了解决方案:
"searchCols": [
{ "search": "Brussels Sprouts" },
{ "search": "Ring spot" }
]