1. What store?
Store is similar to a local warehouse (data storage), including arraystore, directstore, groupingstore, jsonstore, and xmlstore (all sub-classes of store)
It is mainly used for panel display.
Store is composed of a proxy (data source) and a datareader (data interpretation.
1. (proxy) Data source: Generally the value in the background, which is habitually converted into a JSON object to store (Note: personal understanding)
II. (datareader) read data: after obtaining the data, the data needs to be parsed. datareader (the fields attribute is actually a record object) parses the data and specifies the format.
3. Store the stored data to the Panel
2. Important attributes and methods in store
Attributes: data, proxy, reader, URL, root ....
Method: Load
1. if data is configured, the proxy and URL are invalid and you do not need to call the load method to generate a record set.
VaR store = new Ext. data. arraystore ({fields: ['deptno', 'dname', 'loc '], data: ext. datas. mess // reference data. JS data });
2. if data is not configured, you must set proxy or URL or both. If autoload is not set to true,
You must call the load method manually. To obtain data in arrays, JSON, XML, and other formats.
// Jsonstore is responsible for processing JSON objects returned in the background. http: // var store1 = new Ext. data. jsonstore ({autodestroy: True, URL: 'extjstest/extjs_getempbydeptno.action', storeid: 'mystore', root: "EMP", // JSON object group is similar to this object: {EMP: [{empno: 'XX',...}]} fields: [{Name: 'empno', mapping: 'empno', type: 'float'}, {Name: 'ename', mapping: 'ename', type: 'string'}, {Name: 'hiredate', type: 'date', mapping: 'hiredate'}, {Name: 'deptno', mapping: 'deptno', type: 'float'}]});
3. Reader is required to specify the data parser,
You need to specify the corresponding type of parser Based on the obtained data format. (In short, the preceding description indicates that fidlds is an attribute of the record instance created by the datareader object)
4. If no proxy is specified but a URL is specified, httpproxy is used as the data source by default and the URL is used as the parameter during httpproxy instantiation.
var myStore = new Ext.data.Store({reader: myReader,proxy : new Ext.data.HttpProxy({method: "POST",url: 'extjsTest/extjs_getEmpByDeptNo.action',}) });
5. The Root User specifies the JSON group (which is understood by the individual). Check whether the object passed in JSON is clear.
{emp:[{"EMPNO":7369,"HIREDATE":"1980-12-17","ENAME":"SMITH"},{"EMPNO":7499,"HIREDATE":"1981-02-20","ENAME":"ALLEN"},{"EMPNO":7521,"HIREDATE":"1981-02-22","ENAME":"WARD"},{"EMPNO":7566,"HIREDATE":"1981-04-02","ENAME":"JONES"},{"EMPNO":7654,"HIREDATE":"1981-09-28","ENAME":"MARTIN"}]}
Store. Load () represents loading data in the data store... (see the API documentation, Martial Arts secret: http://www.sencha.com/products)