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

Problem using RadToolbar as CommandItemTemplate in RadGrid

3 Answers 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Waliaula
Top achievements
Rank 1
Waliaula asked on 11 Feb 2010, 08:31 AM
I am using a RadToolbar in a RadGrid CommandItemTemplate. The client side OnCommand event does not get fired if one of the items in the toolbar is clicked. This happens even if the item has been configured with the appropriate CommandName i.e New item has a CommandName="InitInsert". Is there a way I can allow the event to bubble up the RadToolbar so that it can reach Rad|Grid and fire the OnCommand event?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2010, 09:51 AM
Hi,

A workaround would be to invoke the fireCommand method on the OnClientButtonClicked of the RadToolBar .This ill inturn fire the OnCommand event of the RadGrid.

JavaScript:
 
<script type="text/javascript"
    function OnCommand(sender, args) { 
        alert("OnCommand fired"); 
    } 
    function OnClientButtonClicked(sender, args) { 
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
        masterTable.fireCommand("InitInsert"""); 
    } 
</script> 

-Shinu.
0
Waliaula
Top achievements
Rank 1
answered on 22 Mar 2010, 01:37 PM
Is it possible to embed RadToolBar as a CommandItemTemplate for a RadGrid and have the RadToolBar invoke RadGrid commands by setting Commandname of RadToolBarItem property without any extra js code. Curremtly I have a similar setup but I have to handle the RadToolBar OnClientButtonClicked and then use the fireCommand() method to invoke the appropriate command. Like so:

function toolBar_OnClientButtonClicked(sender, args) { 
    var command = args.get_item().get_commandName();    
    var tableView = $find(tableViewId).get_masterTableView(); 
 
    if (tableView != null) {           
        if (command == "New") {             
            gridTableView.showInsertItem();            
        } 
    } 

0
Sebastian
Telerik team
answered on 25 Mar 2010, 12:10 PM
Hi Waliaula,

Yes, this is possible by taking advantage of the event bubbling mechanism of RadGrid for ASP.NET AJAX. Examine the implementation from the following online demo for details:

http://demos.telerik.com/aspnet-ajax/toolbar/examples/applicationscenarios/gridcommanditem/defaultcs.aspx?product=grid

Best regards,
Sebastian
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Waliaula
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Waliaula
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or