Click to See Complete Forum and Search --> : DataGrid row selection at client side


narsimha
May 23rd, 2005, 06:36 PM
I have a Datagrid and i need a functionality to set the row of a datagrid to a color(blue) when i click on the DataGrid row. I have a check box in the DataGrid Header if i select the checkbox all the rows in the datagrid are set with the color(blue) at client side. i wrote the code but it is giving problems. can you pls help me out in solving this problem. code is below:

var selectedRow = null;
function fnSelectRow(rowObject)
{
if (selectedRow != null)
{
selectedRow.style.backgroundColor = '#ffffff';
}
selectedRow = rowObject;
selectedRow.style.backgroundColor = '#CAD3E4';
}


function fnSelectAll(chkVal, DataGrid1)
{

if(document.getElementsByTagName)
{
var table = document.getElementById(DataGrid1);
var rows = table.getElementsByTagName("tr");
for (i=0;i<eval(rows.length); i++)
{
rows[i].className="even";
}
if(chkVal == true)
{
for(i = 1; i < eval(rows.length-1); i++)
{

rows[i].className = "odd";
}
}
else
{
rows[1].className = "odd";
for(i = 2; i < eval(rows.length-1); i++)
{
rows[i].className = "even";
}
}
}

}