Accessing the original menu item object during select event

6 posts, 1 answers
  1. Elan
    Elan avatar
    7 posts
    Member since:
    Nov 2011

    Posted 25 Mar 2012 Link to this post

    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
  2. Answer
    Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 27 Mar 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Rob
    Rob avatar
    5 posts
    Member since:
    Mar 2012

    Posted 27 Mar 2012 Link to this post

    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"
    });
  5. Victor Zhang
    Victor Zhang avatar
    1 posts
    Member since:
    Jan 2010

    Posted 18 Oct 2012 Link to this post

    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
  6. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 26 Sep 2013 Link to this post

    I'm still using this technique to get a selected items associated datasource data. Any update on when, or if, this will change?
  7. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 02 Oct 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready