DataGrid Client Side row selection

G

Guest

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.className="even";
}
if(chkVal == true)
{
for(i = 1; i < eval(rows.length-1); i++)
{

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

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top