Parent data accessible via data-bind syntax, but not template syntax

4 posts, 0 answers
  1. Dave
    Dave avatar
    15 posts
    Member since:
    Aug 2013

    Posted 11 Nov 2015 Link to this post

    I'm trying to figure out how to access parent level data using template syntax (#: parentId #) as opposed to data-bind="text: parentId" syntax.  The data-bind syntax finds the parent data, but the template syntax does not.  I'm trying to create a path so I cannot use data-bind syntax.  I've created an example to demonstrate the problem here: 

    http://jsfiddle.net/MadCodeMonkey/uwf5w83x/

    If you remove  #: parentId # from the template, it will work again.

     

    I assume that it is supposed to automatically retrieve parent data the way data-bind works, but perhaps it just doesn't work the same way.

  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 13 Nov 2015 Link to this post

    Hello Dave,

     

    the data-bind approach works because the observables automatically build object hierarchy, necessary for the change detection (and, for that matter, cases like this one) to be handled correctly. Apart from that, a "parent object" concept is not present in the plain javascript objects. They are not "aware" that an object has a reference of them bound to a given field. 

     

     

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Dave
    Dave avatar
    15 posts
    Member since:
    Aug 2013

    Posted 13 Nov 2015 in reply to Petyo Link to this post

     Petyo,

    Thank you.  I just wanted to make sure that I wasn't missing something.  My work around currently is to pass along a copy of the parent fields to the child row objects when they are created on the client side.  It's not ideal, but it works.

     

    I did try putting the parent on the child object, but that generates a "Uncaught RangeError: Maximum call stack size exceeded" error.

     

    Dave

  5. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 17 Nov 2015 Link to this post

    Hello Dave,

     

    Indeed, this is so - assigning the parent to child will produce circular reference, which in many cases trips the JSON serializer.

     

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