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

Can I access a "OnClick" command for TableCell?

4 Answers 619 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 03 Jun 2008, 12:07 AM
I have several TableCells that I'd like to use to link to other pages.  Is there a "click" event for TableCell that I can attach a method to on the server-side?

Also, the RadGrid I am referring to is within the NestedViewTemplate of another RadGrid and that has an "OnItemCommand" method attached to it.  The problem I am experiencing is that I can't seem to isolate a click in the child grid from a click in the parent grid.  No matter which grid the item is in that I click on, it executes the parent's OnItemCommand method.  Is there a way to isolate it or turn that method off for child grids?

Thanks,

Eddie

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2008, 05:18 AM
Hi Eddie,

Try the following code snippet to perform a PostBack on clicking the GridCell.

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            item["ProductName"].Attributes.Add("OnClick"," return Show();");  
        }  
    } 

JS:
 <script type="text/javascript" language="javascript" > 
     
     function Show()  
     {  
      alert("Clicked")  
         __doPostBack("<%= RadGrid1.UniqueID %>");  
     }  
       
    </script> 

Princy.
0
Ricky
Top achievements
Rank 2
answered on 03 Jun 2008, 05:32 AM
Hi

The way i am doing it is by creating GridTemplateColumn and going through a javascript function.

Javascript function

function openredirect(id)

{

window.location=

"redirecttoABC.aspx?iaGUID="+id

}




<telerik:GridTemplateColumn UniqueName="From" HeaderText="From" >

<HeaderStyle Width="10px" HorizontalAlign="Left"></HeaderStyle>

<ItemTemplate>

<itemstyle verticalalign="Left">

<a href="#" id="redirect" style="text-decoration:blink; " onclick="return openredirect('<%# Eval("GUIDFrom") %>');"><span style="color:Green"> <%# Eval("iaGUIDFrom") %></span></a>

</ItemTemplate>

<EditItemTemplate>

</EditItemTemplate>

</telerik:GridTemplateColumn>

0
Software
Top achievements
Rank 1
answered on 03 Jun 2008, 03:10 PM
Thanks for the replies.  I was hoping to run a server-side method when the TabelCell is clicked, not Javascript.  It looks like that's not going to be possible?  I guess I could put a linkbutton in the cell and style it to appear to be the entire cell, but I thought I'd try this first...

Thanks again for the help!

Eddie
0
Shinu
Top achievements
Rank 2
answered on 04 Jun 2008, 04:42 AM
Hi Eddie,

Try setting EnablePostBackOnRowClick to true.

ASPX:
<ClientSettings EnablePostBackOnRowClick="true" > 
            </ClientSettings> 


Thanks
Shinu

Tags
Grid
Asked by
Software
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ricky
Top achievements
Rank 2
Software
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or