I am evaluating igniteUI for use in our project. We use knockout heavily throughout for client behavior. Is there an example that adds/deletes rows from a grid when that grid is bound to a knockout observablearray?
Attached a working sample. Going through the objects in VS, when adding an object to the bound observablearray the tmpDataSource of the grid contains the correct entries but the actual datasource/data/dataview objects never get refreshed even after calling dataBind().
Hi there,
Look at what version of jQuery UI you are currently using. In any version < 1.9 there is a bug with the _createWidget method which creates a deep copy of any non-primitive option, thus creating a deep copy of the observableArray and no longer referring to the same instance as the rest of the elements. This does not happen with version 1.9 and up, the bug has been fixed so you can try switching to this version to see if the issue is still reproducible.
Let us know whether this resolves your issue!
From what I can see there is a bug in the version of infragistics.datasource.knockoutjs.js file I have (which is the latest trial download) in the internal _addrow function the call to _super appeared to have the parameters switched around. The bolded lines below are what I changed and the grid appears to reflect my newly added observable item throughtout all data/datasource and dataview items. Could you please confirm?
_addRow: function (d, c) {
var b = this.kods;
b = ko.isObservable(b) ? b() : b;
if (this.settings.responseDataKey && b[this.settings.responseDataKey]) {
b = b[this.settings.responseDataKey] }
if (ko.isObservable(b)) {
if (!this._koUpdate) {
b.push(d) } else {
this._koUpdate = false;
this._super(d, c)
}
} else {
//CGG
//this._super(c, d)
Konstantin just wondering if you have had chance to investigate further.
Thanks.
Thank you for the reply. I pulled in the latest version of the jquery packages but still see the same results. When adding a new js knockout object to the underlying observable array the grid displays the text of the newly added item. However when you begin editing the newly attached row all fields are empty, the original data is not displayed. When you have finished editing and commit the changes an exception is thrown where it cannot find the 'primarykey' field on the object in edit. From what I can tell, and I am using the latest trial version, is that the grids actual datasource objects are being updated to contain not the js object I add to the observable array but rather the id of the object.
I tried to attach my sample solution as a .zip file but received a 500 error multiple times. Is there an alternate way I could send you the archive? Any incite you can provide is very much appreciated as I feel the grid could be a real timesaver in our project, but the databinding to knockout observables and observable arrays is a must.
Thanks,
Chad