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

geting selected column name

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ibrahim
Top achievements
Rank 1
ibrahim asked on 17 Mar 2009, 07:19 PM
i am trying to create a filtration method where when a cell a combobox will apear for filtring with that column...i just want to get the column name after clicking on the cell? is it possible

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Mar 2009, 07:20 AM
Hi Ibrahim,

You can try the following code snippet to access the column name on the client side when clicking the header of RadGrid.

JavaScript:
<script type="text/javascript" >  
function OnColumnClick(sender, eventArgs)   
{   
     alert("Click on column-header: " + eventArgs.get_gridColumn().get_uniqueName()); 
}   
</script>  

If you want to get the column name when clicking the grid cells, then you can try attaching OnClick event for each column and pass the column name as a parameter to client side function. See the example below.
CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridDataItem) 
    { 
        GridDataItem item = (GridDataItem)e.Item; 
        item["CategoryName"].Attributes.Add("OnClick""return getColumn('" + "CategoryName" + "');"); 
        //Do the same for each Column
    }  

Then at clicent side:
<script type="text/javascript"
function getColumn(un)       
{                      
    alert(un);
}     
</script> 

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