menu, onclick(..) allowed? & hide/show items

4 posts, 0 answers
  1. Marco
    Marco avatar
    2 posts
    Member since:
    Apr 2012

    Posted 05 Apr 2012 Link to this post

    Hi, i just dl your framework to try if covers all my needings, i have 2 question (please dont call me stupid if i didnt understood it before :) )
     
    1)
    i'm wondering if its right to add onclick event to a <li> markup, something like:

      <ul id="menu">
                    <li>
                        File
                        <ul>
                            <li onclick="alert('ciao');">sub1</li>
                            <li onclick="doSomething(....);">sub2</li> 
    .....
    i cant use the onSelect handler as shown in your demos becouse user can change it, and also may exists same text in different places of the menu
    seems to work..

    2) i see that exists insert/add and remove items, does exists also an hide/show methods?

    thx
  2. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 06 Apr 2012 Link to this post

    Hello Marco,

    1. I'm not sure I understand why you don't want to use the select event, but yes - you should be able to attach event handlers with onclick="something()" too.

    2. You can hide the LI elements directly with jQuery show()/hide() or with CSS only (display: none).

    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. Marco
    Marco avatar
    2 posts
    Member since:
    Apr 2012

    Posted 06 Apr 2012 Link to this post

    thanks for quick reply,
    1)id like to follow your official guidelines becuse if the library will be (accepted by the boss bought) my code will be compatible with your further versions. as i understood, i can check only the text property of the selected item, but id like to have some custom data;
     i did a small editing to the demo page /web/menu/events.html
    ...
         function onSelect(e) {
                        //kendoConsole.log("Selected: " + $(e.item).children(".k-link").text());
                        for(var propertyName in $(e.item).children(".k-link")) {
                            kendoConsole.log(propertyName);
      
                        }
    ..
    but im unable to find a possible place where to put my own (hidden to end user) data..
    how to add my additional data for the LI markup? and how to read it on the event 

    2) perfectly right, forgive me for this question.. sometimes i need a rest :)

    thanks again for patience


  5. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 09 Apr 2012 Link to this post

    Hi Marco,

    Currently there's no official way to store additional data on an item. We intend to offer this functionality as part of the menu hierarchical data source support we have planned. Meanwhile there are a number of ways to do this, ranging from manually iterating the items and assigning them the data to keeping the additional data in the JSON object and finding it when needed. The latter should be a better alternative since it doesn't involve iteration on init. Check the following implementation in jsFiddle:


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