In Ext.data.Model
class we have set(fieldName, newValue)
method which sets one model field to the given value.
How to set multiple values at one time? Something like:
Ext.data.Model.set({
field1: 'value1',
field2: 345,
field3: true
});
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model
You can set the field to set, or an object containing key/value pairs
record.set({
field1: value,
field2: value2
});
// or
record.set(field1, value);
record.set(field2, value2);
That's not possible, but as per my understanding you only want to merge this different calls for setting a value in model when you need to notify about changes in model only once to store so store will only fire update
event once
If this is the case for you then you can use beginEdit
and endEdit
functions
var model = new Ext.data.Model();
model.beginEdit();
model.set('field1', 'value1');
model.set('field2', 345);
model.set('field3', true);
model.endEdit();
Just create a new record which returns a blank record with all the model fields
//this one is for the grid model
var blank_record = Ext.create(grid.store.model);
Create an object to set the new values to fields
var new_record = {
'field1':'value1',
'field2':'value2',
'field3':'value3'
};
then set the object values to the blank record
blank_record.set(new_record);
Further if u want to add the newly created record to the grid
grid.store.add(blank_record);
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With