[英]How to collect all the id values for a yadcf filtered table
I'm using datatables and yadcf to filter a table.我正在使用数据表和 yadcf过滤表。 Now I'd like to take all the table row id values, for example, and use those as arguments in a POST request.例如,现在我想获取所有表行 id 值,并将它们用作 POST 请求中的参数。 How can I "collect" the values of these ids from the result of the filters that have been applied?如何从已应用的过滤器的结果中“收集”这些 id 的值? I've seen this example , which doesn't seem to apply to yadcf , but is similar to my use-case.我看过这个例子,它似乎不适用于yadcf ,但与我的用例相似。
I was able to get the information I wanted using the answer found here<\/a> .我能够使用此处<\/a>找到的答案获得我想要的信息。 I didn't realize that jQuery will select only the visible elements, which is what I want.我没有意识到 jQuery 只会选择可见元素,这正是我想要的。 So, after applying the yadcf<\/strong> filter to my table it's simple to select all the tr.id values resulting from the filter.因此,在将yadcf<\/strong>过滤器应用于我的表后,选择过滤器产生的所有 tr.id 值很简单。
"Yes, the submit content is only the visible row with datatables.是的,提交内容只是带有数据表的可见行。
If you have 5 rows and after filter 2 rows, if you click on submit button with the active filter only 2 rows will be submitted.如果您有 5 行并且在过滤 2 行之后,如果您单击带有活动过滤器的提交按钮,则只会提交 2 行。
And if, conversely, you still wanted to submit all the elements of the table despite the filtering, on the onsubmit there is a yadcf function that you just have to execute which deactivates all active filtering to submit the entire table like this :相反,如果您仍然想提交表格的所有元素,尽管过滤了,在 onsubmit 上有一个 yadcf 函数,您只需执行该函数即可停用所有活动过滤以提交整个表格,如下所示:
var table = $('#mytable').DataTable( {}) ;
document.onsubmit = function(){
yadcf.exResetAllFilters(table) ;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.