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

TreeView get ID of checked node

3 Answers 471 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 05 Sep 2014, 11:43 PM
Hi, I want to get the id of the checkbox the user clicks on, but it doesn't seem like it's working.  Thank you all in advance.

@(Html.Kendo().TreeView()
    .Name("treeview")
    .HtmlAttributes(new {@class="demo-section" })
    .Checkboxes(checkboxes => checkboxes
        .Name("checkedGuide")
        .CheckChildren(true)
    )
    .DataTextField("Name")
    .DataSource(dataSource => dataSource
        .Read(read => read
            .Action("GetTree", "AuthService")
        )
    )
)

<script>

    $("#treeview").on("change", ":checkbox", function (e) {
        var data = $("#treeview").data('kendoTreeView').dataItem(e.node);
        alert(data.id);
    });

</script>

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 08 Sep 2014, 07:00 AM
Hello Philip,

Instead of manually wiring up the checkbox change event, use the newly introduced check event (since 2014.Q2.SP1) -- it will give you the e.node parameter that is unavailable in jQuery event handlers.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Philip
Top achievements
Rank 1
answered on 08 Sep 2014, 06:12 PM
Hello Alex,

Thanks for you reply.  I will not be able to update to the new version, currently I'm using (2014.1.318), is there any way I can get the ID without my current version?

Thanks
0
Alex Gyoshev
Telerik team
answered on 09 Sep 2014, 08:11 AM
Hello Philip,

Yes, you can. Instead of using e.node in the event handler, use e.target. Here is a Dojo snippet that shows this.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
Philip
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Philip
Top achievements
Rank 1
Share this question
or