Easyui DataGrid usage notes

Source: Internet
Author: User

Reference Category: a note in WCF

<table id="Table_User"></table>

Background JS

VaR user_id; var totalcount; $ (function () {$. ajax ({type: 'get', URL: '/service/gettotalcount', // obtain the total number of records contenttype: 'application/json', success: function (data) {totalcount = data; getusers (10, 1) ;}}) ;}); function getusers (pagesize, pagenumber) {// get a page var jsondata = {'pagesize': pagesize, 'pagenumber': pagenumber}; var message = JSON. stringify (jsondata); $. ajax ({type: 'post', URL: '/Servic E/getusers ', // obtain the record contenttype: 'application/json', data: Message, datatype: 'json', success: function (data) on a page) {// data is the object array [{'key': value, 'key': Value}, {'key': value, 'key ': value}] var STR = {Total: totalcount, rows: Data}; // Total: Total number of records, rows: object array // bind the foreground <Table id = "table_user"> </table> $ ('# table_user '). dataGrid ({Title: 'user management', singleselect: True, // only single row width: 800, height: 'auto', nowrap: false, // Newline collapsible: false, fitcolumns: True, autorowheight: false, // toolbar: toolbar, // toolbar, see the jeasyui.com description rownumbers: True, // display the row number fitcolumns: true, pagination: True, // display pagenumber: pagenumber on the page turning toolbar, // key: Pass in the current page pagesize: pagesize, // key: Pass in the size of each page pagelist: [10, 20, 30], // you can adjust the size of each page. Method: 'get', // The default value is post. sortname: 'user _ num' as needed ', // sortorder: 'asc 'for single-page sorting, // remotesort: false in ascending order, // sort showfoote by Client R: false, idfield: 'user _ id', columns: [{checkbox: true}, {field: 'user _ id', Title: 'id', width: 30, align: 'left', sortable: true}, {field: 'user _ name', Title: 'user name', width: 100, align: 'left ', sortable: true}, {field: 'user _ num', Title: 'num', width: 100, align: 'left', sortable: true}, {field: 'created _ at', Title: 'create at', width: 100, align: 'left', sortable: true}, {Field: 'Created _ by', Title: 'created by', width: 100, align: 'left', sortable: true}, {field: 'Modified _ at', title: 'Modified at', width: 100, align: 'left', sortable: true}, {field: 'Modified _ by', Title: 'Modified by', width: 100, align: 'left', sortable: true}, {field: 'date _ from', Title: 'date from', width: 100, align: 'left', sortable: true}, {field: 'date _ to', Title: 'date to', width: 100, Align: 'left', sortable: True, Styler: function (value, row, index) {// you can adjust the cell style here. // If (value = '2014/1/0301') {// return 'color: red ;'; // }}}], onclickrow: function (rowindex, rowdata) {// click get user_id = rowdata. user_id;}, ondblclickrow: function (rowindex, rowdata) {// double-click to enter a page // self. location = "/doc_mi/mi_detail.aspx? Milistid = "+ rowdata. mi_list_id + "& milistnum =" + rowdata. mi_list_num;}, rowstyler: function (index, row) {// you can adjust the style var d = new date (row. date_to); var n = new date (date. now (); If (row. date_to! = NULL & D <n) {return 'background-color: red; color: white' ;}}); $ ('# table_user '). dataGrid ("loaddata", STR); var PG =$ ('# table_user '). dataGrid ("getpager"); If (PG) {$ (PG ). pagination ({onselectpage: function (pagenumber, pagesize) {getusers (pagesize, pagenumber); // page turning key points }}}, error: function (error) {console. log (error. responsetext );}});}

WCF Service:

Using system. servicemodel;
Using system. servicemodel. activation;
Using system. servicemodel. Web;
Using BLL;
Using model;

...

[Servicecontract]
[Aspnetcompatibilityrequirements (requirementsmode = aspnetcompatibilityrequirementsmode. Allowed)]
[Servicebehavior (concurrencymode = concurrencymode. Single)]
Public class service
{

...

[WebGet(UriTemplate = "/GetTotalCount",        ResponseFormat = WebMessageFormat.Json,        RequestFormat = WebMessageFormat.Json)]        public int GetTotalCount()        {            return BLL.BLLL_MNG_USER.GetTotalCount();        }        [WebInvoke(UriTemplate = "/GetUsers",         BodyStyle = WebMessageBodyStyle.WrappedRequest,        ResponseFormat = WebMessageFormat.Json,        RequestFormat = WebMessageFormat.Json)]        public List<MODEL_MNG_USER> GetUsers(int pageSize, int pageNumber)        {            return BLLL_MNG_USER.GetUsers(pageSize, pageNumber);        }
}

Web. config

<system.serviceModel>    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">      <serviceActivations>        <add relativeAddress="Service.svc" service="Service.service"  factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"/>      </serviceActivations>    </serviceHostingEnvironment>  </system.serviceModel>  <system.webServer>    <modules runAllManagedModulesForAllRequests="true"/>  </system.webServer>

Gloab. asax

using System.ServiceModel.Activation;using System.Web.Routing;using Service;...protected void Application_Start(object sender, EventArgs e)        {            WebServiceHostFactory serviceHostFactory = new WebServiceHostFactory();            RouteTable.Routes.Add(new ServiceRoute("Service", serviceHostFactory, typeof(service)));                   }

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.