Updating/refreshing ViewModel in UI after Bind

2 posts, 0 answers
  1. Neeraj
    Neeraj avatar
    135 posts
    Member since:
    May 2015

    Posted 12 Jun 2017 Link to this post

    Hello,
              I have ViewModel that has Array. "TicketVMList"   .

    Code:

    TicketviewModel= kendo.observable({         

    TicketVMList:  @Html.Raw(Json.Encode(Model)),         

    GetTicketNumber: function(e) {             

                    debugger;             

                GetTicketNumberProcess(e);        

                },         

    OnTicketTstCheck: function(e) {

                              debugger;

                           OnTicketTSTCheckProcess(e);

              }     });

     

    Initially it bind using :

    kendo.bind($("#TicketItemContainer"), TicketviewModel.TicketVMList);   //works well

     

    but there is click event on which i am making ajax call and i send this TicketVMList and it load some values inside it and send in response. On success i have tried various ways to refresh UI with new response that i received  ( TicketItemContainer is Div that i am binding to )

    success: function (result) {                 debugger;                 
                        //kendo.unbind($("#TicketItemContainer"));                 
                        //kendo.bind($("#TicketItemContainer"),result);                 
                    kendo.unbind($("#TicketItemContainer"));                 
                  TicketviewModel.TicketVMList = result;                 kendo.bind($("#TicketItemContainer"), TicketviewModel.TicketVMList); 
                    //var vm2 = kendo.observable(result);                 
                //$.extend(TicketviewModel.TicketVMList, vm2);                 //kendo.bind($("#TicketItemContainer"), TicketviewModel.TicketVMList); 
                    kendo.ui.progress($("#TicketItemContainer"), false);             
    },

     

     

    Even i have tried commented code , but it doesnt work.

  2. Dimitar
    Admin
    Dimitar avatar
    796 posts

    Posted 14 Jun 2017 Link to this post

    Hello Neeraj,

    On the following Dojo example you will find a Kendo UI MVVM example which is identical to the described scenario.

    I have setup a button, which requests data from a remote service and on success updates the ViewModel. To update the TicketVMList I have used the Kendo Model set() method as follows:
    TicketviewModel.set("TicketVMList", data);

    I hope this resolves your issue.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top