PDA

View Full Version : How to add records in json



neosky
6 Dec 2013, 3:32 AM
Hello i have some problem.
i have store with:



fields: [
{name: 'id',type: 'int'},
{name: 'name',type: 'string'},
{name: 'author',type: 'string'},
{name: 'year',type: 'string'},
{name: 'price',type: 'string'}, ],

and json json={"id":1,"author":"2","options":[{"name":"NAME","value":"3"},{"author":"american","value":"4"}]}
i have a form with grid (id,name,author,year,price) and button, and when i am click on button a new form show with 5 textfields(id,name,author,year,price)/ This textfields for create new record . And how add a new record.

scottmartin
6 Dec 2013, 5:43 AM
You can use the following options:



var myrec = { name: 'new name'};
store.insert(0,myrec);




// Create a model instance
var rec = Ext.create('Employee', {
name: 'New Guy',
email: 'fng@sencha.com',
start: new Date(),
salary: 60000,
active: true
});

store.insert(0, rec);


Scott.