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

Cancel RowClick event

7 Answers 444 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 10 Feb 2009, 12:28 PM

Hello,

(I am using the Q3 2008 release of the ASP.NET ajax components)

I have a RadGrid with "EnablePostBackOnRowClick" enabled. I only want this postback to occur in certain situations though. In the older versions of the RadGrid, I could have a javascript handler that did t his:

function radGrid_RowClick(sender, eventArgs)

{

    eventArgs.set_cancel(true);

}

But, this does not work with the Q3 2008 release. What is the equivalent functionality?

Kind regards,

Andy

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2009, 01:43 PM
Hello Andy,

RowClick client-side event cannot be canceled in the current version of RadControls for ASP.NET AJAX. You can refer to the following forum link which discusses on a similar scenario:
set_cancel in OnRowClick event

Thanks
Princy.
0
Andy
Top achievements
Rank 1
answered on 10 Feb 2009, 02:13 PM

Hi

Thanks for your response. I notice in the other forum topic, no alternative was given, so I assume there isn't one. In which case, can anyone suggest a work around for my problem?

In my RadGrid, I need to fire a postback when a row is clicked on, unless the element they are clicking on is a checkbox.

Kind regards,

Andy

0
Daniel
Telerik team
answered on 10 Feb 2009, 02:21 PM
Hello Andy,

It is possible to disable postback by default (EnablePostBackOnRowClick="false"). In this way you can invoke postback or ajax request manually.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andy
Top achievements
Rank 1
answered on 10 Feb 2009, 02:36 PM

Hi,

Thank you for your response. Is it possible for you to give me sample javascript code that I could use to invoke a Postback as though the postback were being caused by clicking on a row when EnablePostBackOnRowClick is true?

Kind regards,

0
Princy
Top achievements
Rank 2
answered on 11 Feb 2009, 07:49 AM
Hello Andy,

You can try out the following code enable postback on click of the row on client side when EnablePostBackOnRowClick is set to false.
aspx:
<telerik:RadGrid AllowCustomPaging="true" ID="RadGrid2" runat="server"
       <MasterTableView > 
        .... 
       </MasterTableView>         
        <ClientSettings EnablePostBackOnRowClick="False">          
        <ClientEvents OnRowSelected="RowSelected"/>                
         <Selecting AllowRowSelect="True" /> 
        </ClientSettings> 
 </telerik:RadGrid> 

js:
function RowSelected(row, args) 
           { 
             var e = args.get_domEvent();    
             var targetElement = e.srcElement || e.target;                
             if(targetElement.tagName.toLowerCase() != "input" && (!targetElement.type || targetElement.type.toLowerCase() != "checkbox"))// && currentClickEvent)  
                 {  
                      alert("Clicked on Row");  
                     __doPostBack('<%=RadGrid2.ClientID %>');  
                      
                 }  
             else  
                 {  
                      alert("Clicked on CheckBox");                        
                 }  
               
            } 

Thanks
Princy.
0
Moon
Top achievements
Rank 2
answered on 13 Apr 2010, 03:41 PM
I tried your rowclick example and it errors on this line:
doPostBack('<%=grdReviewer.ClientID %>');  


object expected error...

here is what it creates when stepping through...

 

 

doPostBack('ctl00_ctl00_ContentPlaceHolder1_ContentBody_ReviewerControl_ReviewerGrid_grdReviewer');  

 

0
Princy
Top achievements
Rank 2
answered on 14 Apr 2010, 08:05 AM
Hello Moon,

The __doPostback is ASP.NET's way of doing javascript postbacks. Make sure that you have tried  __doPostBack (instead of doPostBack).

Thanks,
Princy.
Tags
Grid
Asked by
Andy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andy
Top achievements
Rank 1
Daniel
Telerik team
Moon
Top achievements
Rank 2
Share this question
or