Ext. Data-groupingstore/jsonstore/simplestore

Source: Internet
Author: User
Tags autoload

Ext. Data. groupingstore

Inherited from Ext. Data. Store and added the grouping function for store. Other usage is the same as that for store. The only thing you need to note is that you must specify sortinfo information when using groupingstore.
Added configuration attributes.
Groupfield: String // field used for grouping
Grouponsort: Boolean // if it is true, the sorting fields are regrouped. The default value is false.
Remotegroup: Boolean // remote sorting
Of course, there will be one more group method.
Groupby (string field, [Boolean forceregroup]): void
As the name implies, they are all re-ordered.

The following is a simple example.
VaR arr = [[1, 'bene', 'binladen '], [2, 'dump', 'binladen'], [3, 'dump ', 'lamp'];
VaR reader = new Ext. Data. arrayreader (
{ID: 0 },
[
{Name: 'name', mapping: 1 },
{Name: 'occupation', mapping: 2}
]);

VaR store = new Ext. Data. groupingstore ({
Reader: reader,
Groupfield: 'name ',
Grouponsort: True,
Sortinfo: {field: 'occupation', ction: "ASC"} // you must specify sortinfo information when using groupingstore.
});
Store. loaddata (ARR );

// Gridpanel will be discussed later. It is used here to intuitively express groupingstore
VaR grid = new Ext. Grid. gridpanel ({
DS: store,
Columns :[
{Header: "name", width: 20, sortable: True, dataindex: 'name '},
{Header: "Occupation", width: 20, sortable: True, dataindex: 'occupation '}
],
View: New Ext. Grid. groupingview ({
Forcefit: True,
Grouptexttpl: '{text} ({[values. Rs. Length]} {[values. Rs. length> 1? "Items": "item"]})'
}),
Frame: True,
Width: 700,
Height: 450,
Collapsible: True,
Animcollapse: false,
Title: 'groupexample ',
Renderto: 'div _ gridpanel'
});

Ext. Data. jsonstore

It is also a store subclass, with the goal of making it easier to use JSON objects as data sources.
Fields and root are added in the structure. The usage is as follows:
/*
This is a remote object. The returned content is consistent with the data of the local object below.
VaR store = new Ext. Data. jsonstore ({
URL: 'jsoncallback. js'
,
Root: 'rows ',
Fields: ['id', 'name', 'occupation']
});
Store. Load ();
*/
VaR store = new Ext. Data. jsonstore ({
Data: {'results': 2, 'rows ':[
{'Id': 1, 'name': 'Bill ', Occupation: 'gardener '},
{'Id': 2, 'name': 'ben', Occupation: 'horticulturalist '}
]},
Autoload: True,
Root: 'rows ',
Fields: ['id', 'name', 'occupation']
})

// Skip gridpanel before proceeding
VaR grid = new Ext. Grid. gridpanel ({
DS: store,
Columns :[
{Header: "ID", width: 200, sortable: True, dataindex: 'id '},
{Header: "name", width: 200, sortable: True, dataindex: 'name '},
{Header: "Occupation", width: 200, sortable: True, dataindex: 'occupation '}
], Height: 350,
Width: 620,
Title: 'array grid ',
Renderto: 'div _ gridpanel'
});

Ext. Data. simplestore

Create a store object more conveniently from an array object,
Example
VaR store = new Ext. Data. jsonstore ({
Data :[
[1, 'bill ', 'gardener'], [2, 'ben', 'horticulturalist']
],
Autoload: True,
Fields: [{Name: 'name', mapping: 1}, {Name: 'occupation', mapping: 2}]
})
VaR grid = new Ext. Grid. gridpanel ({
DS: store,
Columns :[
{Header: "name", width: 200, sortable: True, dataindex: 'name '},
{Header: "Occupation", width: 200, sortable: True, dataindex: 'occupation '}
], Height: 350,
Width: 620,
Renderto: 'div _ gridpanel'
});

Author name: blackant2
Author blog: http://blog.csdn.net/blackant2

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.