Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
iggrid not rebinding data when observable array changes.
posted

I have iggrid which complains about the grid feature "Updating" to be added to dynamically rebind the grid but after I do add that feature, it throws an error of "newds" is not a function. I am using durandal and binding it to an observable array. How do i rebind the grid in this scenario? My product is 14.2 ignite UI.

Parents
No Data
Reply
  • 23953
    Offline posted

    Hello Renison,

    Here are 2 approaches:

    1) Re-creating the grid (faster from performance perspective)

    var model, gridOpts = {
    	primaryKey: "contactID1",
    	features: [
    		{
    			name: "Updating", 
    			editMode: "none",
    			enableAddRow: false,
    			enableDeleteRow: true, 
    			columnSettings: [ ]
    		}
    	]
    };
    
    $(function () {
    	model = ko.mapping.fromJS(dataSource);
    	gridOpts.dataSource = model.data;
    	ko.applyBindingsToNode($("#grid")[0], { igGrid: gridOpts }, model);
    });
    
    var rebind = function () {
    	ko.cleanNode($("#grid")[0]);
    	ko.mapping.fromJS(dataSource, model);
    	ko.applyBindingsToNode($("#grid")[0], { igGrid: gridOpts }, model);
    }
    

    2) Re-populating the observable array (slower from performance perspective)

    ds.removeAll(); 
    ds.push(newRecord); 
    ds.valueHasMutated();
    

    Hope this helps,
    Martin Pavlov
    Infragistics, Inc.

Children