jQuery Easyui學習教程之實現(xiàn)datagrid在沒有數(shù)據(jù)時顯示相關提示內(nèi)容
本示例實現(xiàn)easyui datagrid加載/查詢數(shù)據(jù)時,如果沒有相關記錄,則在datagrid中顯示沒有相關記錄的提示信息,效果如下圖所示
本實例要實現(xiàn)如下圖所示的效果:
本示例easyui版本為1.3.4,如果運行后沒有效果,自己檢查easyui版本
不同版本對appendRow和mergeCells支持不一樣,參數(shù)不一致什么的。
無法隱藏分頁導航容器,可以用chrome開發(fā)工具或者firebug查看分頁導航容器的樣式和原始datagrid table表格的關系。
源代碼如下
$(function () { $('#dg').datagrid({ fitColumns: true, url: 'product.json', pagination: true, pageSize: 3, onLoadSuccess: function (data) { if (data.total == 0) { //添加一個新數(shù)據(jù)行,第一列的值為你需要的提示信息,然后將其他列合并到第一列來,注意修改colspan參數(shù)為你columns配置的總列數(shù) $(this).datagrid('appendRow', { itemid: '<div style="text-align:center;color:red">沒有相關記錄!</div>' }).datagrid('mergeCells', { index: 0, field: 'itemid', colspan: 4 }) //隱藏分頁導航條,這個需要熟悉datagrid的html結構,直接用jquery操作DOM對象,easyui datagrid沒有提供相關方法隱藏導航條 $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide(); } //如果通過調(diào)用reload方法重新加載數(shù)據(jù)有數(shù)據(jù)時顯示出分頁導航容器 else $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show(); }, title: 'easyui datagrid沒有數(shù)據(jù)顯示無數(shù)據(jù)提示信息', width: 550, columns: [[{ field: 'itemid', width: 80, title: 'Item ID' }, { field: 'productname', width: 100, editor: 'text', title: 'Product Name' }, { field: 'listprice', width: 80, align: 'right', title: 'List Pirce' }, { field: 'unitcost', width: 80, align: 'right', title: 'Unit Cost'}]] }); }); product.json {"total":0,"rows":[]}
以上所述是小編給大家介紹的jQuery Easyui學習教程之實現(xiàn)datagrid在沒有數(shù)據(jù)時顯示相關提示內(nèi)容的全部敘述,希望對大家有所幫助,如果大家有任何問題歡迎給我留言,小編會及時回復大家的!
下面給大家介紹 jQuery EasyUI datagrid 無記錄時,增加"暫無數(shù)據(jù)"提示
在 datagrid 的onLoadSuccess事件進行操作:
onLoadSuccess: function (data) { if (data.total == 0) { var body = $(this).data().datagrid.dc.body2; body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 35px; text-align: center;"><h1>暫無數(shù)據(jù)</h1></td></tr>'); } }
- easyUI使用分頁過濾器對數(shù)據(jù)進行分頁操作實例分析
- jQuery EasyUI API 中文文檔 - Pagination分頁
- jQuery EasyUI datagrid實現(xiàn)本地分頁的方法
- jQuery EasyUI Pagination實現(xiàn)分頁的常用方法
- EasyUi datagrid 實現(xiàn)表格分頁
- EasyUI Pagination 分頁的兩種做法小結
- SSh結合Easyui實現(xiàn)Datagrid的分頁顯示
- EasyUi+Spring Data 實現(xiàn)按條件分頁查詢的實例代碼
- EasyUI折疊表格層次顯示detailview詳解及實例
- EasyUI加載完Html內(nèi)容樣式渲染完成后顯示
- easyUI 實現(xiàn)的后臺分頁與前臺顯示功能示例
相關文章
jquery ezUI 雙擊行記錄彈窗查看明細的實現(xiàn)方法
下面小編就為大家?guī)硪黄猨query ezUI 雙擊行記錄彈窗查看明細的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-06JQuery的html(data)方法與<script>腳本塊的解決方法
在使用Jquery的html(data)方法執(zhí)行寫數(shù)據(jù)到Dom元素時遇到一個問題:在data參數(shù)中包含script腳本塊的時候,html(data)方法的執(zhí)行結果與預期不符2010-03-03獲得所有表單值的JQuery實現(xiàn)代碼[IE暫不支持]
通過jquery獲取所有表單值,一般都是后臺語言處理的,這里通過jquery獲取,確實不錯的想法2012-05-05jQuery實現(xiàn)B2B網(wǎng)站后臺管理系統(tǒng)側(cè)導航
這篇文章主要介紹了jQuery實現(xiàn)B2B網(wǎng)站后臺管理系統(tǒng)側(cè)導航,文中示例代碼非常詳細,幫助大家更好的理解和學習,感興趣的朋友可以了解下2020-07-07