我在我的應用程序中使用easyui datagrid。當沒有記錄返回時,如何在表中顯示消息(例如:沒有找到記錄!)?如何在沒有記錄返回時在表格中顯示消息(例如:沒有找到記錄!)?
$('#test').datagrid({
onLoadSuccess:function(data){
if(data.total == 0){
alert("No Records founds");
}
}
});
我在我的應用程序中使用easyui datagrid。當沒有記錄返回時,如何在表中顯示消息(例如:沒有找到記錄!)?如何在沒有記錄返回時在表格中顯示消息(例如:沒有找到記錄!)?
$('#test').datagrid({
onLoadSuccess:function(data){
if(data.total == 0){
alert("No Records founds");
}
}
});
我在jeasyui論壇中發現了一些解決方案。請參考以下
http://www.jeasyui.com/forum/index.php?topic=1881.msg4135#msg4135
基於鏈路的鏈路我改變了我的代碼以下變化
$('#test').datagrid({
onLoadSuccess:function(data){
showGridMessage($('#test'));
}
})
function showGridMessage(target){
var opts = $(target).datagrid('options');
var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
vc.children('div.datagrid-empty').remove();
if (!$(target).datagrid('getRows').length){
var d = $('<div class="datagrid-empty"></div>').html('No Records Found').appendTo(vc);
d.css({
position:'absolute',
left:0,
top:50,
width:'100%',
textAlign:'center'
});
}else{
vc.children('div.datagrid-empty').remove();
}
}
請總結您的答案中的鏈接;這樣,如果鏈接失效,答案不會完全無用。 – michaelb958 2013-07-26 04:43:16
謝謝您的建議..... – user1934095 2013-07-26 07:54:24
你需要做的是 同時選擇從數據庫中的數據,您需要檢查結果行是否大於0 如果它大於0只是以格式解析數組$sampledata[$i]['nameof_field1'] = $dataresult->column;
如果select中沒有數據,那麼您n EED具有相同的格式,但空值$sampledata[0]['nameof_field1'] = '';
解析,那麼你可以試試這個代碼
onLoadSuccess:function(data){
if(data.nameof_field1==''){
alert("No Records founds");
}
}
如果你告訴我們,你已經嘗試了我們將幫助您解決這個問題。 – 2013-05-06 13:17:26
到目前爲止,我使用警報通過檢查onloadsuccess的總數來顯示消息,但現在我的需求已經發生變化。我瞭解瞭如何動態添加新行。 – user1934095 2013-05-06 13:42:50
你可以發佈你的代碼嗎? – 2013-05-06 14:51:51