Home  >  Article  >  Web Front-end  >  Data access and update issues in ExtJS Store_extjs

Data access and update issues in ExtJS Store_extjs

WBOY
WBOYOriginal
2016-05-16 18:28:25872browse

You can use add(Ext.data.Record[] records) or add(Ext.data.Record record) to add one or more records to the end of the store. For example:

Copy code The code is as follows:

var newRecord=new PersonRecord({name:" Tom",age:22});
store.add(newRecord);

The add function will add new data to the end of the store, which may change the original sorting method. Cause damage, if you want to keep order, you should use addSorted, the calling method is the same as add.
You can use the insert method to insert a record into a specified location, such as:
Copy code The code is as follows:

var newRecord=new PersonRecord({name:"Tom",age:22});
store.insert(store.getCount(),newRecord);

Delete Operations can use the remove and removeAll functions, such as:
Copy code The code is as follows:

store. remove(store.getAt(0));
store.removeAll();

Modify the data in the store:
Copy Code The code is as follows:

store.getAt(0).set("name","Jesse");

Modification After recording the internal data, you can undo all modifications by executing rejectChanges(), or commit data modifications by commitChanges.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn