when adding a record to a datatable the method changeid gets called
however, the depends and triggers attributes associated with math columns mean that the system reports an error
adding a couple of lines to the changeid method deleting the depends and triggers attributes fixes the problem (the missing attributes end up getting added back properly in math mixin)
code at line 9879
changeId: function (old, newid) {
//assert(this.pull[old],"Can't change id, for non existing item: "+old);
if (old == newid) return;
if (this.pull[old]) this.pull[newid] = this.pull[old];
this.pull[newid].id = newid;
**delete this.pull[newid].depends;**
**delete this.pull[newid].triggers;**
this.order[this.order.find(old)] = newid;
if (this._filter_order) this._filter_order[this._filter_order.find(old)] = newid;
if (this._marks[old]) {
this._marks[newid] = this._marks[old];
delete this._marks[old];
}
this.callEvent("onIdChange", [old, newid]);
if (this._render_change_id) this._render_change_id(old, newid);
delete this.pull[old];
},
Basically, changeId is called by Webix only when the backend assigns its own ID of a saved record (in this case, Webix will update client-side ID according to the response).
But the bug (it is the bug, thank you for reporting!) appears one step later. It is specific to a certain use-case:
In this case, after changeId was called, the record is also updated with updateItem, assuming the response from the server contains some other data fields to update. At this point, math fails with the new id/triggered data update/old math hash (depends/triggers) and throws the error.
However, please note that customization of changeId method in Webix sources to a specific use-case can severely affect maintainability of the project.
As a safer workaround (untill the issue is fixed from our side), consider using onBeforeDataSend event of DataProcessor to delete the same fields for newly added recods (considering the server does not change IDs for existing recods and their updates).
If you have faced this issue with a use-case that is different from my assumption, please let me know about the details. Thanks!
UPD: the issue can be repeated in a simple sequence of updates, and same workaround will work with onIdChange event of component’s DataStore (line 41-44): Code Snippet
Note: the UPD section was important to me - I am overriding “save” with a function that calls changeId explicitly. The code snippet in your UPD section was what fixed the problem.
The use of the" ->" in “data->onIdChange” is pretty interesting - is it actually documented anywhere?
I feel more comfortable with webix.js reverted to original.