Get RadToolBarItem by Value or CommandName

3 posts, 1 answers
  1. Mink
    Mink avatar
    57 posts
    Member since:
    Apr 2009

    Posted 27 Aug 2009 Link to this post

    Hi,

    I have a RadToolbar and a RadGrid on one page. Depending on how many row are selected in the grid some buttons in the toolbar should be active or inactive.
    To achieve this I run a javascript function every time a row gets selected or deselected in the grid and I go through a switch-case to set the buttons in the right state.
    So far so good, this is just some background to my problem.

    My problem is that, as far as I can see, the only way to get the buttons I want to change is through the toolBar.get_items().getItem() method which takes an integer for the index of the desired item. The problem with that is that I now have to identify button by order in which they are placed, resulting in maintenance hell should the order of the buttons change.
    Rather, I would like to ask the RadToolBarItemCollection collection to get me an item by specifying it's Value or CommandName.
    Obviously it's not very hard to write a small function that gives me this behaviour myself, but I was wondering if it doesn't already exist and maybe I've overlooked it.
    Or that there is a similar but easier approach to getting a specific button from a toolbar through it's Value or CommandName or something similar.

    Regards,

    Mink

  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 28 Aug 2009 Link to this post

    Hi Mink,

    Please, refer to the RadToolBar Client Object help topic. You can use one of the following methods:

    • findItemByText
    • findItemByAttribute
    • findItemByValue


    All the best,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mink
    Mink avatar
    57 posts
    Member since:
    Apr 2009

    Posted 31 Aug 2009 Link to this post

    Ah, great!

    Of coarse! I just couldn't believe something like this wasn't already there, I only expected to find it in toolBar.get_items() and not in toolBar itself.
    Sorry, should have looked better. But thanks for showing me where to find it.

    Regards,

    Mink
Back to Top