function onChange(e) <== What's up with e.sender? Doesn't seem to be a complete reference

3 posts, 1 answers
  1. Michael
    Michael avatar
    19 posts
    Member since:
    Oct 2011

    Posted 17 Jun 2013 Link to this post

    Inside selContentItem() shouldn't e.sender be the kendoListView and thus the same as (in this case) $('#contentListView').data('kendoListView')? When I break and debug, it looks like it (though == returns false), but e.sender.dataSource is empty.

    $('#contentListView').kendoListView({
            dataSource: data
            , template: kendo.template($("#template").html())
            , selectable: "single"
            , schema: {
                model: {
                    children: "Children"
                    , id: "id"
                    , hasChildren: "hasChildren"
                }
            }
            ,change: selContentItem
        });
      
    function selContentItem(e) {
        //I would expect the following to return true and if it did (and similar logic followed), the next line would work nicely but it doesn't because the first line returns false. Why?
      
        console.log(e.sender == $('#contentListView').data('kendoListView'));
        console.log(e.sender.dataSource.view()[e.sender.select().index()]);
      
    }
  2. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 18 Jun 2013 Link to this post

    Hello Michael,

    Both e.sender and this in the context of the ListView change event are reference to the ListView itself. Here is an example for that:

    http://jsbin.com/eselul/2/edit

    Regards,
    Nikolay Rusev
    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. Michael
    Michael avatar
    19 posts
    Member since:
    Oct 2011

    Posted 18 Jun 2013 Link to this post

    Thank you. My mistake was purely logical. Apparently I was very tired.  I was trying to compare a TreeView with a ListView  :)
Back to Top