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

Accessing the original menu item object during select event

5 Answers 258 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Elan
Top achievements
Rank 1
Elan asked on 25 Mar 2012, 09:12 PM
Hi,

I am trying to specify a value with the menu item when I add it to the menu. When I inspect the menu.dataSource I can see the value I specified during initialization, however I don't see a way to associate the select event's e.item object to the menu.dataSource[N] object that the li was created from.

My goal is to store a value with each menu item that is NOT the text of the menu.

Any guidance is appreciated.

Thanks,

Elan

5 Answers, 1 is accepted

Sort by
0
Accepted
Kamen Bundev
Telerik team
answered on 27 Mar 2012, 02:26 PM
Hello Elan,

Unfortunately currently there's no integrated way to access the dataSource item on select. This feature will come naturally with the introduction of a hierarchical structures support in Kendo DataSource and the possibility to bind Menu and PanelBar to it, since every item in the DataSource receives an unique ID which you can use to access it.

That said, it is possible to access the initial menu item in the dataSource option JSON with some javascript/jQuery magic. Check the following jsFiddle for how you can do it:


Regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Rob
Top achievements
Rank 1
answered on 27 Mar 2012, 04:20 PM
I added the following code to open a dialog window for an about button on my main menu...

if(dataItem.value == "about")
{
var window = $("#aboutWindow").data("kendoWindow");
window.center();
window.open();
}


$("#aboutWindow").kendoWindow({
actions: ["Refresh", "Maximize", "Minimize", "Close"],
title: "About this app",
visible: false,
draggable: true,
height: "300px",
modal: true,
resizable: false,
width: "500px"
});
0
Victor Zhang
Top achievements
Rank 1
answered on 18 Oct 2012, 08:53 PM
I am using the following code to create menu dynamically. 
                $.getJSON("web api url",
                    function (data) {
                        menu.append(data);
                    }
Your technique does not work because menu.options.dataSource is null in select event. please help
0
Josh
Top achievements
Rank 1
answered on 26 Sep 2013, 08:43 PM
I'm still using this technique to get a selected items associated datasource data. Any update on when, or if, this will change?
0
Kamen Bundev
Telerik team
answered on 02 Oct 2013, 07:15 AM
Hello Joshua,

No, HierarchicalDataSource support is not yet available for Kendo Menu. Unfortunately I can't give you a time frame either, as there is not much interest shown about this in our Kendo UserVoice feedback page.

Regards,
Kamen Bundev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Elan
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Rob
Top achievements
Rank 1
Victor Zhang
Top achievements
Rank 1
Josh
Top achievements
Rank 1
Share this question
or