How can I make a grid recognize when a JSON property changes from null to a value and mark it as isDirty?
{
"prop1": null,
"prop2": "",
"prop3": "my val"
}
When a user edits the prop1 cell in an Ext.grid.EditorGridPanel for the first time, it is not marked as dirty. However, on the second edit, it is correctly marked as dirty. The issue seems to be with handling null values when using record.set().
set : function(name, value){
var encode = Ext.isPrimitive(value) ? String : Ext.encode;
if(encode(this.data[name]) == encode(value)) {
return; //always returns here if value is null
}
Update:
The workaround is to set the raw value for the data property of a record:
data = segments[i]; //my JSON
recMetadata = Ext.data.Record.create(store.fields.items);
r = new recMetadata({}, data.MyID); //blank record with ID
for (j in data) {
//r.set(j, data[j]); //does not set the data property if null
r.data[j] = data[j]; //set raw value and all is fine with isDirty etc.
}
store.insert(0, r);