ExtJS Learning Notes (6) _ Pagination Gridpanel

Source: Internet
Author: User
Tags serialization

I. WCF component

1. By viewing the official example, the paging data source needs a record total value, in order to maintain versatility, here for reference to Jillzhang's article http://www.cnblogs.com/jillzhang/archive/2008/06/29/ 1232086.html, take the generic class Pagedata he wrote and use it directly.

1 using System;
2 using System.Runtime.Serialization;

4 namespace AJAX_WCF
5 {
6 [DataContract]
7 Public Class pagedata<t>
8 {
9 [DataMember]
Ten public int Totolrecord
One {get; set;}

[DataMember]
Public T Data
{get; set;}
}
17}

2. Service-side WCF method: Getdatabypage

[OperationContract]
[WebInvoke (method = "*", Responseformat = Webmessageformat.json,uritemplate = " Getdatabypage?start={start}&limit={limit} ")]
public pagedata<t_class[]> getdatabypage (int start, int Limit)
{
Pagedata<t_class[]> _result = new pagedata<t_class[]> ();
using (dbdatacontext db = new db DataContext ())
{
Try
{
iqueryable<t_class> query = db. t_classes;
_result.totolrecord = query. Count ();
var query2 = query. by (c => c.f_rootid). ThenBy (c => c.f_orders). Select (c => new {f_id = c.f_id, F_classname = c.f_classname, F_parentid =
C.f_parentid, f_orders = C.f_orders, F_R Eadme = C.f_readme}). Skip (Start). Take (limit);
_result.data = db. Executequery<t_class> (Query2, True). Toarray<t_class> ();
}
Catch {}
db. Connection.close ();
}
Return _result
}

Here's a little tip, which is also learned from Jillzhang, the class that was previously dragged out of the LINQ to SQL (DBML) Designer, the default generated code is not serializable, and we can only add [DataContract] and [DataMember] manually,

In fact, the system can be generated automatically by setting the "serialization mode" to "one-way" in the DBML property bar, as shown in the following figure:

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.