Ext.toolbar.Paging pagination Toolbar control in EXTJS4

Source: Internet
Author: User
Tags json
The code is as follows Copy Code

[Js]
var store = ext.create (' Ext.data.Store ', {
Fields: [' intdata ', ' stringdata ', ' timedata '],
Pagesize:15,
Proxy: {
Type: ' Ajax ',
URL: ' Pagingtoolbar1json ',
Reader: {
Type: ' JSON ',
Root: ' Rows ',
Totalproperty: ' Results '
}
},
Autoload:true
});


The code for the corresponding service-side MVC is as follows:

The code is as follows Copy Code

[C # MVC]
Public Jsonresult Pagingtoolbar1json (int start, int limit)
{
var json = new
{
Results = BasicData.Table.Count,
rows = BasicData.Table.Skip (start). Take (limit). Select (x => New
{
Intdata = X.intdata,
StringData = X.stringdata,
Timedata = x.timedata.toshortdatestring ()
})
};
Return JSON (JSON, jsonrequestbehavior.allowget);
}


Now we borrow the Ext.view.View control from the previous article and place it in a panel with the following code:

The code is as follows Copy Code
[Js]
var panel = ext.create (' Ext.panel ', {
Renderto: "Div1",
Frame:true,
width:535,
Autoheight:true,
Collapsible:true,
Layout: ' Fit ',
Title: ' Pagination control used in view ',
Items:Ext.create (' Ext.view.View ', {
Store:store,
TPL:TPL,
Autoheight:true,
Multiselect:true,
ID: ' View1 ',
Overitemcls: ' Hover ',
Itemselector: ' Tr.data ',
Emptytext: ' No data ',
Plugins: [
Ext.create (' Ext.ux.DataView.DragSelector ', {}),
Ext.create (' Ext.ux.DataView.LabelEditor ', {dataindex: ' Intdata '})
]
}),
Bbar:Ext.create (' Ext.toolbar.Paging ', {
Store:store,
Displayinfo:true,
Items: [
'-', {
Text: ' 10th page ',
Handler:function () {
Store.loadpage (10);
}
}]
})
});


Note The above code, we have a button in the Pagination toolbar control, when the button is clicked, the dataset automatically turns to page tenth.

Finally, let's look at the results:

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.