MVVM with remote data

4 posts, 0 answers
  1. Mike
    Mike avatar
    13 posts
    Member since:
    Apr 2016

    Posted 20 Nov 2018 Link to this post

    How can I use the tree view with MVVM while at the same time only fetching the nodes that I need.  The sample shows setting up the observableHierarchy and that is it.  Is it even possible?

     

    I know i can set hasChildren to be true on the parent, but how do i then grab the children?

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1220 posts

    Posted 22 Nov 2018 Link to this post

    Hi Mike,

    In order to load TreeView nodes from remote endpoint on demand, you could use a kendo.data.HierarchicalDataSource object instead of the observableHierarchy available in the demo sample. Here you could find a simple Dojo implementing such scenario.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Mike
    Mike avatar
    13 posts
    Member since:
    Apr 2016

    Posted 22 Nov 2018 in reply to Veselin Tsvetanov Link to this post

    What do I lose by switching? Will i be able to add items to the datasource and the control automatically updates still? I have a need for both cases, the remote is more for the initial load only.

     

    I've been experimenting and with the virtualization, we may just send our dataset down in hierarchial form and call it a day.  I don't see any major performance issues as of yet even with a large amount of root nodes.

  4. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1220 posts

    Posted 26 Nov 2018 Link to this post

    Hello Mike,

    As far as I can understand, you would like to load initially the nodes in the TreeView using a remote call and add new nodes to the widget dynamically at a later stage. If this is the case, you should add the new item using the DataSource.pushCreate() method. That would add the new item to the DataSource locally without trying to syncing its new state with the remote. Here you will find a small sample implementing such scenario.

    As per the TreeView load on demand functionality, it is implemented to fit scenarios in which considerable amount of data could be bound to the TreeView. Keep in mind that if too many nodes are expanded and displayed in the browser simultaneously, that would result in considerable amount of DOM elements present in the browser, which may cause some delays in the rendering of the page.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top