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); //重绘方法
} 展开
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); //重绘方法
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询