我们如何在 jQuery 数据表调用结果而不是页面就绪函数中启动另一个 jQuery 插件?
How can we initiate another jQuery plugin inside jQuery Datatable call results instead of page ready function?
对于我的 Web 应用程序,我使用 jQuery 数据表和 ajax 从 database.Actually 获取数据 'icheck' 在 jQuery 页面准备就绪 function.What 问题是在调用数据表或数据表中发生任何过滤器或搜索后,正确获取数据并且 icheck 复选框显示为正常复选框。
怎么回忆datatable里面的icheck插件调用call.My代码如下
<table id="viewcat" class="table table-bordered table-striped mar-bottom0 mydatatable">
<thead>
<tr>
<th style="width: 9%"><input type="checkbox" class="minimal" id="bulkDelete" /> <button type="submit" id="deleteTriger" name="submit" class="btn btn-primary btn-xs hor-align" value="Delete Selected" >Delete</button></th>
<th style="width: 2%">Sl.no</th>
<th style="width: 15%">Category Name</th>
<th style="width: 20%">Reference Links</th>
<th style="width: 25%">Image</th>
<th style="width: 15%"></th>
<th style="width: 10%"></th>
</tr>
</thead>
</table>
脚本如下
<script>
$(function (){
$("#viewcat").DataTable({
"fnRowCallback" : function(nRow, aData, iDisplayIndex){
$("td:nth-child(2)", nRow).append(aData[7]);
return nRow;
},
"processing": true,
"serverSide": true,
"order": [ 2, "asc" ],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ],
"ajax":{
url :"maincategory/viewdata.php", // json datasource
type: "post",
error: function(){
$(".viewcat-error").html("");
$("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>');
$("#viewcat_processing").css("display","none");
}
}
});
});
</script>
请帮我解决一下..
哦..我终于找到了..这可能会帮助其他人..一个 api 函数而不是 ajax 成功已经存在于数据表插件中..那就是 "fnDrawCallback" .
<script>
$(function (){
$("#viewcat").DataTable({
"fnRowCallback" : function(nRow, aData, iDisplayIndex){
$("td:nth-child(2)", nRow).append(aData[7]);
return nRow;
},
"fnDrawCallback": function( oSettings ){
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass: 'iradio_minimal-blue'
});},
"processing": true,
"serverSide": true,
"order": [ 2, "asc" ],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ],
"ajax":{
url :"maincategory/viewdata.php", // json datasource
type: "post",
error: function(){
$(".viewcat-error").html("");
$("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>');
$("#viewcat_processing").css("display","none");
}
}
});
});
</script>
对于我的 Web 应用程序,我使用 jQuery 数据表和 ajax 从 database.Actually 获取数据 'icheck' 在 jQuery 页面准备就绪 function.What 问题是在调用数据表或数据表中发生任何过滤器或搜索后,正确获取数据并且 icheck 复选框显示为正常复选框。 怎么回忆datatable里面的icheck插件调用call.My代码如下
<table id="viewcat" class="table table-bordered table-striped mar-bottom0 mydatatable">
<thead>
<tr>
<th style="width: 9%"><input type="checkbox" class="minimal" id="bulkDelete" /> <button type="submit" id="deleteTriger" name="submit" class="btn btn-primary btn-xs hor-align" value="Delete Selected" >Delete</button></th>
<th style="width: 2%">Sl.no</th>
<th style="width: 15%">Category Name</th>
<th style="width: 20%">Reference Links</th>
<th style="width: 25%">Image</th>
<th style="width: 15%"></th>
<th style="width: 10%"></th>
</tr>
</thead>
</table>
脚本如下
<script>
$(function (){
$("#viewcat").DataTable({
"fnRowCallback" : function(nRow, aData, iDisplayIndex){
$("td:nth-child(2)", nRow).append(aData[7]);
return nRow;
},
"processing": true,
"serverSide": true,
"order": [ 2, "asc" ],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ],
"ajax":{
url :"maincategory/viewdata.php", // json datasource
type: "post",
error: function(){
$(".viewcat-error").html("");
$("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>');
$("#viewcat_processing").css("display","none");
}
}
});
});
</script>
请帮我解决一下..
哦..我终于找到了..这可能会帮助其他人..一个 api 函数而不是 ajax 成功已经存在于数据表插件中..那就是 "fnDrawCallback" .
<script>
$(function (){
$("#viewcat").DataTable({
"fnRowCallback" : function(nRow, aData, iDisplayIndex){
$("td:nth-child(2)", nRow).append(aData[7]);
return nRow;
},
"fnDrawCallback": function( oSettings ){
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass: 'iradio_minimal-blue'
});},
"processing": true,
"serverSide": true,
"order": [ 2, "asc" ],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ],
"ajax":{
url :"maincategory/viewdata.php", // json datasource
type: "post",
error: function(){
$(".viewcat-error").html("");
$("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>');
$("#viewcat_processing").css("display","none");
}
}
});
});
</script>