how to use model.set() with nested object

2 posts, 0 answers
  1. maayan
    maayan avatar
    5 posts
    Member since:
    Aug 2014

    Posted 26 May 2016 Link to this post

    hi everyone

    on my grid have this two fields


     <input  data-bind="value:GroupName" name="GroupName" > field on the root level of the object

     <input  data-bind="value:ThresholdsbSettings.Hold.Value" name="TransactionsHoldAllowedWarning" > nesting on the  root level of the object

    i need to be able to change the model object before submit to server 

    this is how i do it and it works only for the GroupName field

        var model = $("#mid_groups_grid").data("kendoGrid").dataSource.getByUid(uid);
        model.set("GroupName", null);

    when i try to use this code on the nested object (TransactionsHoldAllowedWarning)

    it will not change it but it will be added to the root object for some reason (look at the attached picture) 

     

    any ideas how to how to use model.set with nested object

    thank u

  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 27 May 2016 Link to this post

    Hello maayan,

     

    I'm not sure what is the exact cause for the behavior you have described looking at the provided information. Therefore, could you please provide a small runnable sample which to demonstrate the issue you are facing.

    Setting a nested object value via the set method of the ObservableObject should be done similar to the following - model.set("my.nested.object.path", 42);

     

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top