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                                   

            });

        }

           

Parents
No Data
Reply
  • 5513
    Offline posted

    Hello,

    When you try to reload your view model with a new set of data, the grid will try to find the differences between the two and apply them without re-rendering itself. This is one of the key features of the grid's Knockout integration, however it can be slow with very big chunks of data, which might be what's causing this freezing. What is the amount of records the server sends in your case? Could you please share which version of Ignite UI you are using?

    I am looking forward to hearing from you!

    Best regards,

    Stamen Stoychev

Children