View Full Version : Editing Records and JSON null values

10 Mar 2011, 2:55 AM
If I have a JSON returned with null values for a property, how do I force a grid to recognise a value has changed from null and mark it as isDirty?

"prop1": null,
"prop2": "",
"prop3": "my val"
} The first time a user edits the prop1 cell in a Ext.grid.EditorGridPanel it is not marked as dirty, however as soon as it is edited a second time it is. Empty strings work correctly on the first edit.

Do I need to convert all my nulls with a reader to undefined if numbers, and empty strings otherwise?

10 Mar 2011, 11:56 PM
The workaround I cam up with 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);

I added a question at http://stackoverflow.com/questions/5258412/extjs-json-records-with-null-values