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

onCellClick method or equivalent ?

2 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maxime
Top achievements
Rank 1
Maxime asked on 03 Jul 2012, 09:12 AM
Hello world,

Currently working with RadGrid of telerik "RadControls for ASP.NET AJAX Q2 2012" version, I try to perform an event by clicking on a cell. I read the following topic : http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

But it is not exactly what I want. By double clicking on a cell, i want to open a simple alert window wich display cell information instead of an edit form, and not all information of the row. This event must happen on some cells only, depending on an argument (true or false test) Is there any simple way to perform this ?

Thanks.

  • ASP.NET version: 4.0
  • OS: WS2008R2
  • exact browser version: Firefox 13.0 & IE9.0
  • exact version of the Telerik product: RadControls for ASP.NET AJAX Q2 2012
  • preferred programming language : C#

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Jul 2012, 09:45 AM
Hello,

Try the following code to access the cell value in on click method.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
      GridDataItem item = (GridDataItem)e.Item;
       TableCell cell = (TableCell)item["UniqueName"];
       string id=cell.ClientID;
       cell.Attributes.Add("onclick","Show('"+id+"');return false;");
     }
}
JS:
function Show(id) {
     var cell = document.getElementById(id);
     alert(cell.innerHTML);
}

Thanks,
Shinu.
0
Maxime
Top achievements
Rank 1
answered on 04 Jul 2012, 07:12 AM
Thank you, it works :)

Maxime.
Tags
Grid
Asked by
Maxime
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Maxime
Top achievements
Rank 1
Share this question
or