Problem with dataBound event on nested list

6 posts, 0 answers
  1. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 11 Jun 2014 Link to this post

    Hello

    I have viewModel that is created from remote dataSource

    var viewModel = window.kendo.observable({
                dataSource: data.dataSource,
                dataBound: function() {
                   // do something
                }
    });

    this view model is bound to list:

    <div class="list edit-form"
                data-role="listview"
                data-source="{ 'pageSize': 5 }"
                data-bind="source: dataSource"
                data-auto-bind="false"
                data-template="list-line-template">
           </div>
           <div class="pager k-pager-wrap"
                data-role="pager"
                data-source="{ 'pageSize': 5 }"
                data-bind="source: dataSource"
                data-auto-bind="false">

    Inside list there is nested sublist with is bound with:

    <div class="form-group-indent" data-bind="source: SubList" data-template="list-subline-template">
                   </div>

    Everything is working except one thing, I need to run some code after all list is finished loading and finished binding: I tried

    events: { dataBound: dataBound }

    on list element, but this is fired too soon, before sublist is bound.
    When I add the same in place where sublist is bound, the even is not fired, becuase I beleive it si trying to find function inside nested element, not on root.

    So my question is how to add event handler to dataBound event from viewModel (parent), or is there any event that is called when everything is bound, all parent and child items to listview?

    Regards
    Marcin


  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 13 Jun 2014 Link to this post

    Hello Marcin,

    I am afraid there is no such event, the parent does not know how many records there are below (how many children there are) and if there are children of the children. I am afraid there is no suitable solution to this case.

    Kind Regards,
    Petur Subev
    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. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 13 Jun 2014 in reply to Petur Subev Link to this post

    eh, that's a pity, I think it would be at least usefull to be able to call some global method e.g. assiciated to window. But currently even that is not possible. The best would be to have some parent selector.

    Regards
    Marcin
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 16 Jun 2014 Link to this post

    Hello Marcin,

    On a side note I would like to provide some additional information just for the record. You can use jQuery to select children or parent. For example to get any existing child of a parent Grid you can use the following:

    $("#masterGridID").find(".k-grid").each(function(){
        var childGrid = $(this).data("kendoGrid");
          //...
    })

    However the issue here is that there is not event to know that every child is initialized (because the child Grid are initialized when the expand icon is clicked). 

    The opposite traversing (from child to the parent) is also possible.

    var parent = $("#someChildGrid23").parent().closest(".k-grid").data("kendoGrid");

    Kind Regards,
    Petur Subev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 16 Jun 2014 in reply to Petur Subev Link to this post

    Thank for your answer, but this is not my issue.

    I'm using ListView which have biding to elements that have some subelements. All is bound at the same moment but with different template, like with code example I provided. So the is no expand/collapse. All is displayed at once.

    My main problem is that I need an event to know when all bounding operations are finished. To make some custom javascript after everything is already built and displayed.

    The databound event on list view source is fired when main elements are bound. And then subelements are bound, and after that I don't have any information that it was finished. I really don't need information when each group of subelements are bound, but just global information when all job is finished and I can start some post initialization process.

    Regards
    Marcin
  7. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 16 Jun 2014 Link to this post

    Hello again Marcin,

    My apologies I got configured by a similar case with the Grid that I am currently working on - sorry for that. As I covered in my previous post there is no such event which we can use to even count how many times that event was triggered and thus calculate if all the children are bound.

    Feel free to suggest such idea on our official feedback portal where more people can vote for it:

    http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback

    Kind Regards,
    Petur Subev
    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