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

[Solved] To Dynamically add RadToolBarButton to RadToolBar control

1 Answer 16 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kwaku
Top achievements
Rank 1
Kwaku asked on 07 Jan 2011, 08:02 PM
I have a scenario where I would like to dynamically add RadToolBarButton control to R.adToolBar. The HTML and the Javascript are as follows:

HTML:
---------
<telerik:RadToolBar runat="server" ID="RadToolBar2" Width="100%" OnClientButtonClicked="onButtonClicked" >
 <Items>
 </Items>
</telerik:RadToolBar>

Javascript to insert RadToolBarButton control to RadToolBar2:
Initially, a request is made to Controller/Action to determine if button
needs be added. What is failing is the line:
 toolBar.Items.Insert(0, radButton);
It indicates that Items is not defined.
-----------------------------------------------------------------------
// Send a GET Request to Controller/Action
if ('<%=Model.RequestForInfo)%>' == 'True') {
 $.get("/Home/EmployeeInfo", { employeeId: id,
        idType: '<%= Model.TypeId%>'
 },
        function (data) {
           var radButton;
           var toolBar = '<%=RadToolBar2.ClientID%>';

           if (data.IsOk) {
                radButton = new Telerik.Web.UI.RadToolBarButton();
                radButton.Text = "Approve";
                radButton.ToolTip = "Select to approve .";
                toolBar.Items.Insert(0, radButton);
           }
        },
        'json');
}  

Any help will be greatly appreciated.



1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 12 Jan 2011, 02:50 PM
Hi Kwaku,

You should use $find method to get the client-side object of the toolbar as demonstrated here.

Regards,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
General Discussions
Asked by
Kwaku
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or