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

OnRowDblClick do not work with GridTemplateColumn

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Imran Javed Zia
Top achievements
Rank 1
Imran Javed Zia asked on 01 Jul 2010, 04:14 PM

Hi,

We are using RadGrid with GridTemplateColumn which has a table in it with multiple controls. And handling OnRowSelected and OnRowDblClick client side events.
When user clicks some area in table then OnRowDblClick not fired while OnRowSelected works properly. as a work around we used a div outside the table with ondblclick event.

Is there anyother better solution for this as we are getting some other limitation and problem by handling double click through div?

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jul 2010, 02:08 PM
Hello Imran,

 I also experienced this issue when i tried in my end. As a workaround access the GridTemplateColumn from code behind and attach 'ondblclick' client event by passing the ItemIndex to event handler. In the event handler identify the corresponding grid row using this ItemIndex value.

ASPX:
 <telerik:GridTemplateColumn HeaderText="TemplateColumn" UniqueName="GridTemplateColumn"
   <ItemTemplate> 
      <table width="100%" style="height: 100%;"
         <tr> 
           <td> 
              <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
           </td> 
           <td> 
              <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
           </td> 
         </tr> 
       </table> 
    </ItemTemplate> 
 </telerik:GridTemplateColumn> 

C#:
  
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item["GridTemplateColumn"].Attributes.Add("ondblclick""DblClick('"+item.ItemIndex+"');"); 
        } 
    } 

Java Script:
 
 <script type="text/javascript"
      function DblClick(index) 
     { 
        var grid = $find("<%=RadGrid1.ClientID %>"); 
        var MasterTable = grid.get_masterTableView(); 
        var dataItem = MasterTable.get_dataItems()[index];// access grid DataItem using 'index' 
     } 
    
 </script> 
 

Hope this helps,
Princy.



Tags
Grid
Asked by
Imran Javed Zia
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or