I was having an issue with result tree updates as data changes, the system shows an update operation to the ResultTree.dataSourceDataChanged which flows through handleUpdate into updateCache and finally into updateCacheData. In that code if we were not able to find the node matching the update already in the cache it looks for the parent node to see if it's already loaded, if it is then it should treat this as an add rather than an update to an existing record. At first glance the code looks good and clean however on further investigation there appears to be 2 lines which are incorrect. Below is the block of code as available in LGPLed 6.5.1
ResultTree.js lines 653-666
proposed fix:
2 lines have minor changes but major impact
Line 655 is trying to find the parent node, in the original it is looking for any row where the parentIdField matches the parent for the new record, this is incorrect as it will find the first peer to the new node rather than the parent. The fix is to use the variable pk which is previously initializes as the primary key for this datasource.
Line 662 is trying to add the new data into the cache, the original passes the parent node followed by the new row, this is opposite of the other uses of this function (reference addCacheData on line 627) and will attempt to add the parent as a child of this non-existent record.
I've patched my local version however didn't find a patch officially released to resolve this; if one is available and I simply missed it I'm sorry to have wasted your time if however this has not yet been identified please see if it could be incorporated into the next release and/or a patch release to anyone else experiencing the same issue. Thanks
-john
ResultTree.js lines 653-666
Code:
if (node == null) { if (matchesFilter) { var parentNode = this.find(this.parentIdField, updateRow[this.parentIdField]); if (parentNode && (this.getLoadState(parentNode) == isc.Tree.LOADED)) { this.logWarn("updated row returned by server doesn't match any cached row, " + " adding as new row. Primary key value: " + this.echo(updateRow[pk]) + ", complete row: " + this.echo(updateRow)); // duplicate the update row before integrating it into our dataSet updateRow = isc.addProperties({}, updateRow); this.add(parentNode, updateRow); } } continue; }
Code:
if (node == null) { if (matchesFilter) { var parentNode = this.find(pk, updateRow[this.parentIdField]); if (parentNode && (this.getLoadState(parentNode) == isc.Tree.LOADED)) { this.logWarn("updated row returned by server doesn't match any cached row, " + " adding as new row. Primary key value: " + this.echo(updateRow[pk]) + ", complete row: " + this.echo(updateRow)); // duplicate the update row before integrating it into our dataSet updateRow = isc.addProperties({}, updateRow); this.add(updateRow, parentNode); } } continue; }
Line 655 is trying to find the parent node, in the original it is looking for any row where the parentIdField matches the parent for the new record, this is incorrect as it will find the first peer to the new node rather than the parent. The fix is to use the variable pk which is previously initializes as the primary key for this datasource.
Line 662 is trying to add the new data into the cache, the original passes the parent node followed by the new row, this is opposite of the other uses of this function (reference addCacheData on line 627) and will attempt to add the parent as a child of this non-existent record.
I've patched my local version however didn't find a patch officially released to resolve this; if one is available and I simply missed it I'm sorry to have wasted your time if however this has not yet been identified please see if it could be incorporated into the next release and/or a patch release to anyone else experiencing the same issue. Thanks
-john
Comment