Apr 02, 2019, 5:58 AM
How to detect if the store of a grid has changed or is dirty?
I have a forum which has 4 expandable subtabs and one of them has a grid.In this function below I am checking if the tabs have been modified/changed or are "dirty" to be able to save the main tab.
hasDirtyChild(this._firstTab);
hasDirtyChild(this._TabWithGrid);
hasDirtyChild(this._thirdTab);
hasDirtyChild(this._FouthTab);
To add items to the grid, I have seprate window that comes up and saves the item to the grid. However the grid items haven't been saved to the database yet, because the main tab isn't saved yet. So the PK's/ propertyId's of those records are negative right now. So I thought if I check if the store is negative I will then trigger the save function in the backend. It is working, however now, there is an issue where my function is checking all the comboboxes since they all have stores. Is there a way to only check the store of the grids instead of all stores that exist on my forum? I have this function used in a lot of places and I don't want it to cause performance issues by checking all comboboxes stores. I only want to check the stores of grids if they exist. function hasDirtyChild(cnt) {
if (!cnt)
return false;
var ret = false;
Ext.each(cnt.query('*'), function (item) {
if (item.isDirty && item.isDirty()) {
ret = true;
}
if (item.store) {
for (var i = 0; i < item.store.getCount(); i++) {
var record = item.store.getAt(i);
if (record.get(record.idProperty)< 0) {
ret = true;
break;
}
}
}
});
return ret;
}
Last edited by fabricio.murta; Apr 02, 2019 at 6:47 PM.