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

Cancel Postback when EnablePostBackOnRowClick="true"

4 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JustinWong
Top achievements
Rank 1
JustinWong asked on 05 Dec 2010, 08:05 AM
Hi:

I have a RadGrid where I have set EnablePostBackOnRowClick="true".  On special situation, however, when a user click on a specific row (e.g.: if the value on a key is "xyz"), then I don't want the postback to take place. 

I have tried to trap the OnRowSelecting event and was hoping that the following 2 lines of codes could cancel the postback.  However, they don't. The postback occur anyway.
            
eventArgs.set_cancel(true);
return false;

Is there a way to cancel a postback when EnablePostBackOnRowClick="true"?

Justin

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 06 Dec 2010, 05:34 AM
Hello Justin,


One suggestion is to invoke postback explicitly in the OnRowSelecting/OnRowSelected event after checking whether the corresponding cell value is "xyz", and hence no need to set the EnablePostBackOnRowClick property to "True".

More information:
Performing postback from grid client events


-Shinu.
0
Vasssek
Top achievements
Rank 1
answered on 29 Apr 2011, 07:27 PM
Hello,

I have similar issue with EnablePostBackOnRowClick="true. In my radgrid I'm using inline editing. I want to do postback when user clicks on row in radgrid. The problem is, how to stop rising postback when radgrid row is in inline edit mode and user clicks somewhere inside of it. I don't want to use your suggestion workaround with RaisePostBackEvent.

Please help me to solve this issue.

Best regards

Vasssek
0
Iana Tsolova
Telerik team
answered on 04 May 2011, 01:58 PM
Hello Vasssek,

In order to achieve your goal, I would suggest that you disable the postback on row click by default. Then handle the OnRowClick client-side event and fire postback manually only for the cases you need.
Try the attached sample.

Regards,
Iana
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.

0
Vasssek
Top achievements
Rank 1
answered on 09 May 2011, 03:37 PM
Hello Iana,

I've tested your code and it's working perfectly ! Now, I still can resolve e.CommandName values and even more I have a new one: "RowSelect".

I would like to thank you for your help (Extremely helpful: 7 points).

Best regards

Vasssek
Tags
Grid
Asked by
JustinWong
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Vasssek
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or