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

How to call clientside (javascript) function from a button type column click?

1 Answer 365 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kalyani Mantripragada
Top achievements
Rank 1
Kalyani Mantripragada asked on 26 Aug 2010, 08:04 PM
I have a grid column of button type:
<telerik:GridButtonColumn ButtonType=ImageButton ImageUrl="images/Img_Del.gif"></telerik:GridButtonColumn

I want to tie the button click to a javascript function. Is this possible?
I want to do an AJAX call from this function to perform the delete operation and refresh the grid.

 


Appreciate a reply.

thanks

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Aug 2010, 07:19 AM
Hello Kalyani,


Attach OnCommand client event to RadGrid and check for the CommandName in the handler. Thus you can invoke the ajaxRequest if the CommandName matches the ButtonColumn CommandName.

Client code:
<script type="text/javascript">
    function OnCommand(sender, args) {
        if (args.get_commandName() == "CustomDelete") {
            alert("OnCommand");
            // Invoke ajaxRequest to delete the row
            args.set_cancel(true); // Cancel the event
        }       
    }
</script>

Mark-up: Set the CommandName for the column
<telerik:GridButtonColumn  CommandName="CustomDelete" ButtonType="ImageButton" ImageUrl="../Images/del.gif">
</telerik:GridButtonColumn>



-Shinu.
Tags
Grid
Asked by
Kalyani Mantripragada
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or