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

Make column value/item clickable with aim to open a new panel

1 Answer 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jesper
Top achievements
Rank 1
Jesper asked on 23 Feb 2011, 12:11 AM
Hi,
how to make a column value/item clickable and when column value/item clicked open up a new ajax panel in same web page?

Scanario:
  1. A radgrid will be loaded with data and visualized in AjaxPanel1ยจ
  2. Then user clicks a column value/item (ID) for having more information about this row item/value
  3. Then more detailed information about clicked row item/value should be loaded and visualized in AjaxPanel2

All tips/advices for a solution (code) are highly appreciated. I will load data in step 2 and 3 with sql queries. Links to demos and examples are also highly appreciated.

I would prefer to trigger an event when click the column value/item and have the instructions (=code) for action in code behind file. I will also have the column value/item as a link button because in some cases I want two different columns in radgrid that trigger different actions.

Thx in advance! 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Feb 2011, 09:02 AM
Hello Jesper,

The following code snippet shows how to attach 'onclick' event to RadGrid cell.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                dataItem[col.UniqueName].Attributes.Add("onclick", "CellClick('" + dataItem.ItemIndex + "','" + col.UniqueName + "');");//pass parameters accordingly
            }
 
        }
    }

Java Script:
<script type="text/javascript">
     function CellClick(index, uniquename) {
      // do your code
        
    }  
</script>

Hope this helps,
Princy.
Tags
Grid
Asked by
Jesper
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or