dataTables 多条件查询 自定义
程序员文章站
2022-07-13 15:49:46
...
版本: 1.9.4
该版本不支持自定义表单名的查询,需要修改代码
1、修改方法_fnAjaxParameters 添加
2、
var mygridtab = $('#sample_1').dataTable({
"bFilter":true,
"fnStateLoadParams": function (oSettings, oData) {
$("#mySubmit").bind("click", function(){
var oSettings = mygridtab.fnSettings();
oSettings.serverparam=$('#searchform').serializeObject();
oSettings.sDom='';
mygridtab.fnFilter('张是');
/*mygridtab.fnFilter( oSettings, {
"sSearch": val,
"bRegex": oPreviousSearch.bRegex,
"bSmart": oPreviousSearch.bSmart ,
"bCaseInsensitive": oPreviousSearch.bCaseInsensitive
} );*/
});
}
});
3.
该版本不支持自定义表单名的查询,需要修改代码
1、修改方法_fnAjaxParameters 添加
if(oSettings.serverparam){ for(var p in oSettings.serverparam){ aoData.push( { "name": p, "value": oSettings.serverparam[p]} ); } }
2、
var mygridtab = $('#sample_1').dataTable({
"bFilter":true,
"fnStateLoadParams": function (oSettings, oData) {
$("#mySubmit").bind("click", function(){
var oSettings = mygridtab.fnSettings();
oSettings.serverparam=$('#searchform').serializeObject();
oSettings.sDom='';
mygridtab.fnFilter('张是');
/*mygridtab.fnFilter( oSettings, {
"sSearch": val,
"bRegex": oPreviousSearch.bRegex,
"bSmart": oPreviousSearch.bSmart ,
"bCaseInsensitive": oPreviousSearch.bCaseInsensitive
} );*/
});
}
});
3.
$.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; };
上一篇: dom4j 生成完整xml标签内容
下一篇: formpanel表单与json数据绑定