admin管理员组文章数量:1410737
I am using jquery datatables in my MVC4 application. The most simple configuration of jquery datatables.
Infact, I have placed this small jquery snippet in my layout.cshtml file which will take care of all tables in my application without doing anything custom.
$(".dataTable").dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
}).columnFilter();
this works perfectly when I format the table with <thead>, <tbody> and <tfoot>.
Here's the image :
Ofcourse, not everything will work work with this basic configuration.
The problem
The payment status column contains not just some text, it contains a span and a hidden dropdown list. on click of <td>
, The span gets hidden and dropdown bees visible. on dropdown change it reverts back to a visible span and hidden dropdown.
The code :
<td class=" " paymentid="106">
<span>
Completed
</span>
<select name:"paymentstatus"="" style="display:none;" onchange="changepaymentStatus($(this).parent().attr('paymentId'),$(this).val(),10);">
<option value="0" selected="'selected'">Completed</option>
<option value="1">Pending</option>
<option value="2">Cancelled</option>
</select>
</td>
With all this mess present in the <td>
element, it is not able to filter at all (for that column and sorting works incorrectly (for that column).
I am using jquery datatables in my MVC4 application. The most simple configuration of jquery datatables.
Infact, I have placed this small jquery snippet in my layout.cshtml file which will take care of all tables in my application without doing anything custom.
$(".dataTable").dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
}).columnFilter();
this works perfectly when I format the table with <thead>, <tbody> and <tfoot>.
Here's the image :
Ofcourse, not everything will work work with this basic configuration.
The problem
The payment status column contains not just some text, it contains a span and a hidden dropdown list. on click of <td>
, The span gets hidden and dropdown bees visible. on dropdown change it reverts back to a visible span and hidden dropdown.
The code :
<td class=" " paymentid="106">
<span>
Completed
</span>
<select name:"paymentstatus"="" style="display:none;" onchange="changepaymentStatus($(this).parent().attr('paymentId'),$(this).val(),10);">
<option value="0" selected="'selected'">Completed</option>
<option value="1">Pending</option>
<option value="2">Cancelled</option>
</select>
</td>
With all this mess present in the <td>
element, it is not able to filter at all (for that column and sorting works incorrectly (for that column).
1 Answer
Reset to default 3Hi take a look at this http://datatables/examples/plug-ins/sorting_sType.html this will do the job for you.
本文标签: javascriptjQuery datatable custom sorting and filteringStack Overflow
版权声明:本文标题:javascript - jQuery datatable custom sorting and filtering - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744327597a2600803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论