Because the data received by the datagrid is in Json format, we may encounter problems when displaying data on the front end, especially in time format. After Json serialization, the front end cannot display the correct time data, so how can we solve this problem? First, we can use datapattern. js to solve this problem: no nonsense, directly add the Code:
<script src="Scripts/datapattern.js" type="text/javascript"></script>
Copy codeThe Code is as follows:
// List Initialization
Function initTable (searchWhere ){
$ ('# Tt'). datagrid ({
Url: '/UserInfo/GetAllUserInfos ',
Title: 'user list ',
Width: 700,
Height: 400,
FitColumns: true,
IdField: 'id ',
LoadMsg: 'loading user information ...',
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: 'user number', width: 80 },
{Field: 'uname', title: 'username', width: 120 },
{Field: 'pwd', title: 'Password', width: 120 },
{Field: 'phone', title: 'phone', width: 120 },
{Field: 'mail', title: 'mailbox ', width: 120 },
{Field: 'subtime', title: 'registration time', width: 120,
Formatter: function (value, row, index) {// time converted to normal format in Json format
Return (eval (value. replace (// Date \ (\ d +) \ // gi, "new Date ($1 )"))). pattern ("yyyy-MM-dd ");
}
}
],
Toolbar :[
{
Id: 'btnadd ',
Text: 'user registration ',
IconCls: 'icon-add ',
Handler: function (){
ShowCreateDialog ();
}
},
{
Id: 'btndownshelf ',
Text: 'modify user ',
IconCls: 'icon-edit ',
Handler: function (){
UpDateUser ();
}
},
{
Id: 'btndel ',
Text: 'delete a user ',
IconCls: 'icon-cancel ',
Handler: function (){
DelUsers ();
}
},
{
Id: 'btnset ',
Text: 'set User Role ',
IconCls: 'icon-redo ',
Handler: function (){
SetUserRole ();
}
},
{
Id: 'btnsetvip ',
Text: 'set special roles ',
IconCls: 'icon-redo ',
Handler: function (){
SetVip ();
}
}]
});
}
The toolbar refers to the button on the form. It does not seem to be introduced in the api, but can be directly written as an array. It is perfectly displayed:
The image does not match the above Code, just to show the effect;
Easyuidatagrid + asp.net mvc3 sample code (only front-end and Controller): add, delete, modify, and write the example: http://download.csdn.net/detail/a417758082/5215044
Datapattern. js:
Http://download.csdn.net/detail/a417758082/5215139