First I tried to access button by its index, i.e. toolbar.getAllItems(). That worked for some time. But when 1st button is not a button but a dropdown with more buttons in it, that method returns wrong button. Next I tried to access buttons by value. That also worked for some time. But on buttons which may contain child items, like RadToolBarDropDown, that method won't work. Now what do I have to do? Search button by text? My buttons don't have a text at all. So what now?
PLEASE tell me is that a so HUGE problem do add a simple ID property to each button and implement FindButtonByID method? Is that a feature which requires a deep planning? You are developing this control so long and you can't implement this simplest feature? I can't believe that.
11 Answers, 1 is accepted
Can you please clarify if you are trying to find the button on the client-side or on the server side? In case you need on the server side I would suggest that you take a look at the following forum post where it is both explained and exemplified how this could be achieved:
the Telerik team
You could find the specific button by its index value. For instance using the code below you can set visible false to the first button of the RadToolBar control:
the Telerik team
Please have a look into the sample code snippet to access the RadToolBarDropDown from client side.
Alternatively, you can find the button by its attribute name.
(see function: FindItemByAttribute)
The control does not know 'ID' by itself, but, it does allow you to add it as an attribute.
Hence in serverside you can retrieve the right button on do as you like. (recurse button under button as you mentioned)
I hope it helps you or anyone looking for a solution.
Here is a solution in the case of trying to find a drop down toolbar button on the client side. You can use findItemByAttribute in this way (based on example in this forum post).
Define your drop down button as such:
and then in your script you can find it (assuming you already have found your RadToolBar as "rtbar") with:
This information may be in the documentation somewhere, but it was not easy to find. I did not see any specific example that included how to set a drop down attribute and then make a findItemByAttribute call.
Sorry for the error.
In addition to findItemByAttribute(), the findItemByValue() method can also be used to find a button on the client, for example:
You can find these two and other client-side methods of the RadToolBar object in the following documentation article.