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

Determining which column a clicked cell belongs to

6 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 16 Mar 2009, 11:42 AM
Hi everyone

I must be missing something but...

how can I determine which column a clicked cell belongs to (on the client?)


I can see plenty of code examples for row selection and iterating through columns but not for determining which column a cxel belongs to.

many thanks
Richard

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 Mar 2009, 04:37 AM
Hi,

You can use the  "OnColumnClick" client event of the grid to access the column to which the clicked cell belongs:

 
function ColumnClick(sender, eventArgs) 
 
 {  
 
    alert("Click on column-header: " + eventArgs.get_gridColumn().get_element().cellIndex); 
 
 } 
 

You can refer to the link

http://www.telerik.com/help/aspnet-ajax/grid_oncolumnclick.html

Thanks,

Princy


0
ibrahim
Top achievements
Rank 1
answered on 17 Mar 2009, 07:14 PM
ok can i get the column name?
0
Shinu
Top achievements
Rank 1
answered on 18 Mar 2009, 04:07 AM
Hi Ibrahim,

Try the following code snippet to access the column name on the client side.

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


Thanks
Shinu
0
ibrahim
Top achievements
Rank 1
answered on 18 Mar 2009, 06:17 AM
ok first i am a novioce in jscript is a alert like a msgbox??? second i want to be in serverside since i want to change the filtring method accordingly..is it possible
0
Kris
Top achievements
Rank 1
answered on 24 Aug 2009, 03:03 PM
I see that this code works great for clicking on the header for that column. I am trying to determine which column was clicked on when the user clicks on a cell in the grid. Is there a way of accomplishing this?

Thanks in advance
Kris Fuller
0
Kris
Top achievements
Rank 1
answered on 24 Aug 2009, 04:46 PM
I have figured out what I needed to. I just put an if statement in the ItemDataBound event to test if the column is the one i want to fire the event.
Tags
Grid
Asked by
Rich
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
ibrahim
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Kris
Top achievements
Rank 1
Share this question
or