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

Get RadToolBarItem by Value or CommandName

2 Answers 116 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Mink
Top achievements
Rank 1
Mink asked on 27 Aug 2009, 01:58 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 28 Aug 2009, 02:56 PM
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.
0
Mink
Top achievements
Rank 1
answered on 31 Aug 2009, 02:15 PM
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
Tags
ToolBar
Asked by
Mink
Top achievements
Rank 1
Answers by
Peter
Telerik team
Mink
Top achievements
Rank 1
Share this question
or