This is a migrated thread and some comments may be shown as answers.

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

2 Answers 1683 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 17 Jun 2013, 07:37 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 18 Jun 2013, 06:16 AM
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!
0
Michael
Top achievements
Rank 1
answered on 18 Jun 2013, 06:31 PM
Thank you. My mistake was purely logical. Apparently I was very tired.  I was trying to compare a TreeView with a ListView  :)
Tags
ListView
Asked by
Michael
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or