PDA

View Full Version : [CLOSED] enable dirty flag for new row added to grid



susanz
Sep 04, 2014, 10:58 PM
I found this http://forums.ext.net/showthread.php?17198-Adding-row-to-grid discussion and try to use grid.insertRecord(0, rec) got error method not found.
What is easiest way to do this ? (I can do on client or server side) I need show red falg for all cells and the store.getChangedData() or Store.dirty() should recognize this new row.

Thanks
-susanz

This is my JS handler when Add button is clicked:


var AddRow = function (grid, selectedKey, isCopy) {

Ext.Ajax.request({
url: '/Grid/AddRow',
params: {
gridid: gridid,
selectedKey: selectedKey,
isCopy: isCopy
},
success: function (response) {
var rec = Ext.decode(response.responseText).result;
grid.insertRecord(0, rec); // does not work
//grid.store.insert(0, rec); // not show red flag on each cell in new row

}
});

}

GridController.cs

public ActionResult AddRow(int gridid, int selectedKey, bool isCopy)
{
var gModel = new GridModel();
DataRow obj = gModel.InsertNewDataRowToCache(gridid, selectedKey, isCopy);
return this.Direct(obj.RowObject.valuesStorage);


}

Daniil
Sep 05, 2014, 8:36 AM
Hi @susanz,

I think a new record should be considered as a new one and be returned by the Store's .getChangedData() call.

Unless the "rec" variable contains the IDProperty field. Does it contain?

As for marking cells with a red flag. I think it is possible to do... Though, what about this way to mark new records?
http://examples2.ext.net/#/GridPanel/Miscellaneous/Marking_Records/

susanz
Sep 05, 2014, 9:56 PM
Thanks a lots Daniil. I have one more question about IDProperty. I did not specify IDProperty and I don't have column "ID" either. Is it important to have it
or the store create one internally ?
Thanks

Daniil
Sep 06, 2014, 8:54 AM
I think having an IDProperty ModelField is quite important if you are going to save the edited, new, deleted records to the server data store.

IDProperty is "id" by default.

susanz
Sep 07, 2014, 3:13 AM
Thanks! My grid look good now. You can close this.