JQueryEasyUI datagrid架構的進階使用

來源:互聯網
上載者:User

由於datagrid接收資料為Json格式,所以我們在前台展示資料的時候會出現問題,尤其是時間格式,在Json序列化之後,前台無法展示正確的時間資料,那麼我們如何解決這樣的問題呢?首先我們可以使用datapattern.js來解決這個問題:無需廢話,直接上代碼:

<script src="Scripts/datapattern.js" type="text/javascript"></script>

複製代碼 代碼如下:
//列表初始化
function initTable(searchWhere) {
$('#tt').datagrid({
url: '/UserInfo/GetAllUserInfos',
title: '使用者列表',
width: 700,
height: 400,
fitColumns: true,
idField: 'ID',
loadMsg: '正在載入使用者的資訊...',
pagination: true,
singleSelect: false,
pageSize: 10,
pageNumber: 1,
pageList: [10, 20, 30],
queryParams: searchWhere,
columns: [[
{ field: 'ck', checkbox: true, align: 'left', width: 50 },
{ field: 'ID', title: '使用者編號', width: 80 },
{ field: 'UName', title: '使用者名稱', width: 120 },
{ field: 'Pwd', title: '密碼', width: 120 },
{ field: 'Phone', title: '手機', width: 120 },
{ field: 'Mail', title: '郵箱', width: 120 },
{ field: 'SubTime', title: '註冊時間', width: 120,
formatter: function (value, row, index) {//Json格式時間轉化為正常格式
return (eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"))).pattern("yyyy-MM-dd");
}
}
]],
toolbar: [
{
id: 'btnadd',
text: '註冊使用者',
iconCls: 'icon-add',
handler: function () {
showCreateDialog();
}
},
{
id: 'btnDownShelf',
text: '修改使用者',
iconCls: 'icon-edit',
handler: function () {
upDateUser();
}
},
{
id: 'btnDel',
text: '刪除使用者',
iconCls: 'icon-cancel',
handler: function () {
delUsers();
}
},
{
id: 'btnSet',
text: '設定使用者角色',
iconCls: 'icon-redo',
handler: function () {
setUserRole();
}
},
{
id: 'btnSetVip',
text: '設定特殊角色',
iconCls: 'icon-redo',
handler: function () {
setVip();
}
}]
});
}

toolbar指的是表單上面的按鈕,api中好像沒有介紹,但是可以直接以數組的形式寫到上面,完美顯示:

圖片跟上面的代碼不是對應的,只是為了展示個效果;

easyuidatagrid+asp.net mvc3的範例程式碼(只有前台和Controller):增刪改都寫了 樣本:http://download.csdn.net/detail/a417758082/5215044

datapattern.js:
http://download.csdn.net/detail/a417758082/5215139

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.