SmartClient version 7.0rc2
Steps to reproduce the problem:
- create a ListGrid with server side data source (RestDataSource in my case) and with ListGrid.autoSaveEdits set to false
- enable grouping, group by any field
- edit the record
- when an other field, not contained in groupByFields array, is changed, it's value is restored to the old value after executing ListGrid.saveAllEdits().
- the ListGrid.originalData is changed correctly
It seems that the ListGrid.data is not updated after the ListGrid.originalData is changed by ResultSet.updateCacheData() if a field not contained in ListGrid.groupByField is changed.
The problem is probably in method ListGrid.dataChanged(), where ListGrid._markForRegroup is set (and ListGrid.regroup() is called) only in case the field from ListGrid.groupByField is changed.
I haven't found any other place in the source code (except _incrementalRemap(), which is also not called in this case), where ListGrid.data gets sychronized with changes in ListGrid.originalData.
I overloaded the dataChanged() method in my ListGrid derived class, and this solved the problem:
So my question is: am I missing something or it is a SmartClient bug?
Borut
Steps to reproduce the problem:
- create a ListGrid with server side data source (RestDataSource in my case) and with ListGrid.autoSaveEdits set to false
- enable grouping, group by any field
- edit the record
- when an other field, not contained in groupByFields array, is changed, it's value is restored to the old value after executing ListGrid.saveAllEdits().
- the ListGrid.originalData is changed correctly
It seems that the ListGrid.data is not updated after the ListGrid.originalData is changed by ResultSet.updateCacheData() if a field not contained in ListGrid.groupByField is changed.
The problem is probably in method ListGrid.dataChanged(), where ListGrid._markForRegroup is set (and ListGrid.regroup() is called) only in case the field from ListGrid.groupByField is changed.
I haven't found any other place in the source code (except _incrementalRemap(), which is also not called in this case), where ListGrid.data gets sychronized with changes in ListGrid.originalData.
I overloaded the dataChanged() method in my ListGrid derived class, and this solved the problem:
Code:
// force regroup if a field is changed;
// SmartClient forces regroup only if field in groupByField array is changed
// BUT: how it suppose to update a field not included in groupByField?
// TODO: is this a SmartClient bug?
dataChanged: function (type, originalRecord, rowNum, updateData)
{
var undefined;
if (this.groupByField && type == "update") {
var currData = (this.data.isGroupedOutput && this.originalData) ? this.originalData : this.data;
var updatedRecord = currData.get(rowNum);
for (var fieldName in originalRecord) {
if (updatedRecord[fieldName] === undefined || !this.fieldValuesAreEqual(fieldName, originalRecord[fieldName], updatedRecord[fieldName])) {
// XXX incrementalRegroup can handle this case, but more testing is
// necessary. change this post 7.0
// this._incrementalRegroup(updatedRecord, originalRecord, rowNum,
// updateData);
this._markForRegroup = true;
break;
}
}
}
this.Super("dataChanged", arguments);
}
Borut
Comment