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

[Solved] Access CommandName on Client Side

3 Answers 383 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Hollen
Top achievements
Rank 1
Dave Hollen asked on 15 Feb 2010, 09:30 PM
Hello,

I am using a RadGrid and wanted to know how I intercept the grid command name on Client Side.  For example, I have a Delete column on the grid.  When the delete button is clicked, I want to run some client side script and then run some server side script.  What do I need to to in order to have my Javascript pick up the fact that the RadGrid Delete button has been clicked?

Thanks,
Dave

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Feb 2010, 05:06 AM
Hi Dave,

Attach OnCommand event to radgrid and check for the CommandName from client side.

aspx:
 
<ClientSettings> 
    <ClientEvents OnCommand="OnCommand" /> 
</ClientSettings> 

javascript:
 
<script type="text/javascript"
    function OnCommand(sender, args) { 
        if (args.get_commandName() == "Delete") { 
             // Your code 
        } 
    } 
</script> 

-Shinu.
0
Dave Hollen
Top achievements
Rank 1
answered on 16 Feb 2010, 02:30 PM
One more question - how do I get the active row of the grid from within the OnCommand client event?

Thanks!
Dave
0
Tsvetoslav
Telerik team
answered on 18 Feb 2010, 11:14 AM
Hi Dave,

In most cases, you can get the client-side component of the grid row as follows:

var dataItem = args.get_tableView().get_dataItems()[args.get_commandArgument()]

Greetings,

Tsvetoslav
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
Dave Hollen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dave Hollen
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or