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
405
igGrid -browser locks when attempting to refresh a mapped knockout viewModel
posted

My goal is simply to generate a viewModel via Knockout.Mapping, bind a igGrid to the viewModel, and then refresh the viewModel and grid via an ajax call to a controller that returns JSON. I am using VisualStudio 2013 and MVC 5. I have the correct libraries referenced. I am able to get the Infragistics Knockout Integration sample to work correctly, but in the sample there are a lot of hard coded references to column names. I don't want to reference the column names directly, but rather rely on knockout mapping to create my observable viewModel. The initial model binding works fine, and the populated grid is correctly displayed. When I attempt to refresh the grid after the Ajax call, the browser freezes and I have to terminate IE. Can someone show me a simple example of how this can be accomplished?

HTML -
 <table id="grid" data-bind="igGrid: { dataSource: myData,
primaryKey: 'ID', 
features: [{ 
name: 'Updating', 
editMode: 'none',
enableAddRow: false,
enableDeleteRow: true, 
columnSettings: [ ]  }] }"></table>

 

JavaScript -

        $(document).ready(function () {

            var model = @Html.Raw(Json.Encode(Model))

            viewmodel = ko.mapping.fromJS(model)

            ko.applyBindings(viewmodel); };

function getRefreshedModel()

        {          

            $.ajax({

                url:"/Controller/Action/",

                type:'post',

                data: dataString,

                contentType:'application/json',

                success: function (results) { ko.mapping.fromJS(results, viewmodel);  }  //refresh the model and grid                                   

            });

        }