Advanced use of the JQueryEasyUI datagrid framework

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.