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

want to change row color of grid in javascript

1 Answer 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
faisal
Top achievements
Rank 1
faisal asked on 11 Jun 2011, 12:53 PM
Hi, 

i am working on telerik grid. i want to change row color of row in javascript i.e 

 function RadGrid1_RowDataBound(sender, args) {              
                                if (args.get_dataItem()['LastName'] == "owner") {
                                    args.get_item().get_cell('LastName').style.Backcolor ='Red';  // how to do this
                                }
}


plz help

Regards,

Faisal

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Jun 2011, 07:00 AM
Hello Faisal,

Try the following code snippet to set background color for selected row in OnRowSelected event. Hope this helps.

CSS:
<style type="text/css">
 .class1 td  
 {
  background-color:Red;
 }
</style>

aspx:
<ClientSettings  Selecting-AllowRowSelect="true">
<ClientEvents OnRowSelected="OnRowSelected" />
</
ClientSettings>

Javascript:
function OnRowSelected(sender, args)
  {     
 args.get_item().get_element().className = "class1";
  }

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