I have two template check boxes in the row and header of the grid.
I have been able to change the row color on the server side with this code:
CheckBox chkApprove = (CheckBox)sender;
CheckBox chkDeny = (CheckBox)chkApprove.NamingContainer.FindControl("chkDeny");
GridDataItem current = (GridDataItem)chkApprove.NamingContainer;
if (chkApprove.Checked)
{
current.CssClass = "ApproveRow";
chkDeny.Checked = false;
}
else
{
if (current.ItemIndex % 2 == 0)
{
current.CssClass = "GridRow_WebBlue";
}
else
{
current.CssClass = "GridAltRow_WebBlue";
}
}
This is the style sheet info:
.ApproveRow
td
{
background-color: #A7CDB0 !important;
}
I want to do this on the client side to avoid the server delay.
This code will change the check boxes but will not change the row color:
function ApproveClick(index,ApproveChkID,DenyChkID)
{
//alert("In approveclick " + index + " " + ApproveChkID + " " + DenyChkID);
var grid= $find("<%=radAbsence.ClientID %>");
var gridRow=grid.get_masterTableView().get_dataItems()[index];
var chkApprove=document.getElementById(ApproveChkID);
var chkDeny=document.getElementById(DenyChkID);
if(chkApprove.checked==true)
{
chkDeny.checked = false;
alert("chkApprove checked");
grid.get_masterTableView().get_dataItems()[index].className= "ApproveRow";
//alert(" approve index: " + index);
}
else
{
//alert("chkApprove unchecked");
//deselect row
grid.get_masterTableView().get_dataItems()[index].set_selected = false;
if (index % 2 == 0)
{
grid.get_masterTableView().get_dataItems()[index].className = "GridRow_WebBlue";
}
else
{
grid.get_masterTableView().get_dataItems()[index].className = "GridAltRow_WebBlue";
}
}
}
Can you see what is missing, why the row color is not changing?
Steve H.