easyui中加载table列表数据 第一次有数据第二次没有数据问题

 

  $('#allUsingProductTable').datagrid({  加载数据时,第二加载时table会发生变化会出现找不到问题。如果是弹框没有影响,弹框出现出现列表每次都会执行销毁方法。

解决办法

 

 

发送ajax请求获取数据,用$('#usingProductTableUpdate').datagrid('loadData', data.rows);加载数据

$(function(){
$('#usingProductTableUpdate').datagrid({
width: 'auto',
height:'200px',
striped: true,
fit: true,
pagination: true,
scrollbarSize: 0,
singleSelect: true,
url:'',
loadMsg: '数据加载中请稍后……',
columns: [[{
field: 'bad_survey_no',
title: '不良调查编号',
align: 'center',
resizable: false,
width: '10%'
},{
field: 'product_name',
title: '商品名称',
align: 'center',
resizable: false,
width: '15%'
},{
field: 'product_no',
title: '产品编号',
align: 'center',
resizable: false,
width: '18%'
}, {
field: 'starttime_frame',
title: '用药开始时间',
align: 'center',
resizable: false,
width: '18%'
}, {
field: 'endtime_frame',
title: '用药结束时间',
align: 'center',
resizable: false,
width: '18%'
}, {
field: 'common_name',
title: '通用名称',
align: 'center',
resizable: false,
width: '16%'
}
]],
method: 'post',
toolbar: [{
text:'清空',
iconCls: 'icon-help',
handler: function(){
var row=$('#badSurveyTable').datagrid('getSelected');
if(row){
$.messager.confirm('删除数据', '您确定清空数据吗?', function(r){
//清空类表数据
$('#usingProductTableUpdate').datagrid('loadData', {total: 0, rows: []});
});

}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
}]
});
})
function updateUsing(bad_survey_no){

$.post('<%=basePath%>survey/findAddUsingProductmsg.do?bad_survey_no='+bad_survey_no,
function (data) {
//alert(data.rows)
$('#usingProductTableUpdate').datagrid('loadData', data.rows);
},'json');
}

posted @ 2019-12-17 10:12  红尘沙漏  阅读(821)  评论(0编辑  收藏  举报