Create a basic Grid using KnockoutJS Mapping plugin and MVC 3

Create a basic Grid using KnockoutJS Mapping plugin and MVC 3

Asked on December 27, 2018 in knockout js.
Add Comment


  • 1 Answer(s)

        This answer gives the details of using the mapping plugin and mvc for doing the basic grid .

        As the request is done irregularly , The  $.getJSON want the user to transfer the  callback to deal with the result ,.

        So, Try this example code :

    var viewModel = {};
    $.getJSON('WeightTracker/List', function(result) {
        viewModel.stats = ko.mapping.fromJS(result.Data);
        ko.applyBindings(viewModel);
    });
    

    From the above consideration,Its is better to be  binding in the following way .

    <tbody data-bind='template: {name: "statRowTemplate", foreach: stats }'></tbody>
    

    The process is done with a JavaScript object and not a JSON string during doing the  $.getJSON

    Answered on December 27, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.