jquery的datatable 查不到数据就不刷新,查到数据就显示,哪里有问题?

varflag="0";functionloadHouseHoldList(){initHouseHoldListTables();}functioninitHouseH... var flag = "0";

function loadHouseHoldList(){
initHouseHoldListTables();
}

function initHouseHoldListTables() {
$('#householdList_grid').dataTable({
"processing": true,
"serverSide": true,
"deferRender": true,
"ajax": "household/householdList",
"fnServerParams": function( aoData )
{
aoData.unit = flag;
},
"serverMethod":"POST",
"sort": false,
"pagingType": "full_numbers",
"language": {
"url": "assets/plugin/datatables/Chinese.json"
},
"aoColumnDefs": [
{ "data" : "userid",
"aTargets" : [0],
"sWidth" : "50px"
},
{ "data" : "name",
"aTargets" : [1],
"sWidth" : "50px"
},
{ "data" : "sex",
"aTargets" : [2],
"sWidth" : "50px",
"render" : function(data){
if(data == 0){
return "女";
}
else if(data == 1){
return "男";
}
else
return "未知";
}
}
],
"dom": "<'dt-toolbar'<'col-sm-6 col-xs-12'<'#customer-toolbar'>f><'col-sm-6 col-xs-12 hidden-xs'l>>"+
"t"+
"<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>",
"fnInitComplete" : function(oSettings, json) {
$('#customer-toolbar').addClass('dataTables_filter').html('<label class="input" style="padding-right:0.5rem;">'+
'<select style="width:120px;" id="householdSelect" class="form-control select2" onchange="changeBoxmsgStatus()">'+
'<option value="0" selected>全部</option>'+
'<option value="一">一单元</option>'+
'<option value="二">二单元</option>'+
'<option value="三">三单元</option>'+
'<option value="四">四单元</option>'+'</select></label>');
}
});
}

function changeBoxmsgStatus(){
flag = $('#householdSelect').val();
$('#householdList_grid').dataTable().fnDraw(true); //重绘方法
}
展开
 我来答 举报
最柔人天忆16
2018-04-19 · TA获得超过1935个赞
知道小有建树答主
回答量:2.1万
采纳率:33%
帮助的人:1374万
展开全部
uestion: epigenetic dream wh
抢首赞 已赞过 已踩过<
你对这个回答的评价是?
评论 举报 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式