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

[Solved] Accessing the radGrid cell through javscript

2 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
First
Top achievements
Rank 1
First asked on 03 Dec 2009, 02:34 PM
Hi there,

Is there a way to access a particular cell (TD) in radGrid throught javascript?
I need to access the cell, not the content of the cell. I.e I want to change the cell background css etc.
I used to access a normal TD in a table using document.getElementById.
But I noticed radGrid doesn't generate the ID for each cell (TD).
Or maybe I missed something, is there a away to display the ClientID of the Cell / Column for radGrid?

Thanks,

Sxin

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Dec 2009, 03:01 PM
Hello Sxin,

You can try out the following code to achieve the required:
js:
 function GetSelectedNames() 
     { 
    
       var grid = $find("<%=RadGrid1.ClientID %>"); 
       var MasterTable = grid.get_masterTableView(); 
       var Rows = MasterTable.get_dataItems(); 
       for (var i = 0; i < Rows.length; i++) 
       { 
         var row = Rows[i]; 
         var cell = MasterTable.getCellByColumnUniqueName(row, "ColumnUniqueName"
        
        cell.className = "myCell"
         
       }        
 }  
 

css:
 .myCell  
    { 
      background-color:Red; 
    }  

Thanks
Princy.
0
First
Top achievements
Rank 1
answered on 03 Dec 2009, 03:22 PM
Thanks for your fast solution. This is helpful and I appreciate it.
Tags
Grid
Asked by
First
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
First
Top achievements
Rank 1
Share this question
or