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

RadGrid Clientside event Issue

3 Answers 117 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 02 May 2011, 06:27 PM
Hi

I am using form edit in RadGrid. And am using following code.

<asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>&nbsp;
<asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">
</asp:Button>


But the problem is, it not at all firing the client side OnCommand event.

Please help me.


Thanks,
John.

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 04 May 2011, 11:43 AM
Hello John,

As far as I know the grid can raise client Command event only from default grid controls. If you want to raise this from a button inside grid template you can use fireCommand() client side-method:
fireCommand.

Thanks,
Shinu.
0
john
Top achievements
Rank 1
answered on 06 May 2011, 03:08 AM
Thank you very much shinu.

Fire command is working.

In my grid i used fire command to fire insert and update command.In that am validating few mandatory fields and showing alert message.

Message is displaying,but after clicking on ok. It is Posting back. I want to stop that post back.
Even i have given args.set_cancel(true) and return false.


Please help me to stop that post back.

Thanks,
John.
0
Marin
Telerik team
answered on 11 May 2011, 10:15 AM
Hi John,

Normally in this case you should cancel the event and return from the function before calling fireCommand. The ASP button adds a standard __doPostBack call at the end, so you also need to return false after the client side call of the function if you are using such approach. Here is what worked on my end:

<asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" OnClientClick="btnClick();return false;" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

function btnClick()
            {
                if (...something is wrong...)
                {
                    alert("message");
                }
                else
                {
                    //fireCommand(...)
                }
            }

All the best,
Marin
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
john
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
john
Top achievements
Rank 1
Marin
Telerik team
Share this question
or