Finally I used allowrowselect instead of allowrowfocus. And RowClick client side Event. And e.visibleIndex in RowClick client side Event. allowrowselect changes the backcolor itself.
Change DevExpress GridView row back color after SetFocusedRowIndex(-1) by JavaScript
-
31-05-2022 - |
Question
I have a client side function by JavaScipt for FocusedRowChanged
in my ASPxGridView
.
In this function I post gvMore.GetFocusedRowIndex()
to my CallBackPanel
PerformCallback
.
I save FocusedRowIndex
in to ri variable ( var ri = gvMore.GetFocusedRowIndex();
)
and then I remove focus for row ( gvMore.SetFocusedRowIndex(-1);
)
Now how can I Change GridView
row[ri]
color after SetFocusedRowIndex(-1);
?
function OnGridFocusedRowChanged() {
if (gvMore.GetFocusedRowIndex() > -1)
CallBackPanel_FindPlcyCar.PerformCallback(gvMore.GetFocusedRowIndex());
var ri = gvMore.GetFocusedRowIndex();
gvMore.SetFocusedRowIndex(-1);
// *???*
}
what JavaScript code is necessary for ??? Line?
Please answer here and do not redirect me to another link please.
Thanks a lot
La solution 2
Autres conseils
You can use the
OnHtmlRowPrepared="gvMore_HtmlRowPrepared"
on the aspx file at the ASPxGridview tag and implement it as follows on the cs file:
public protected gvMore_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
e.Row.Attributes.Add("id",e.Row.RowIndex.ToString());
}
On the client side you can then change the // ??? part with
document.getElementById(ri).style.Background = "#122334"
or whatever other color you might want. I have not executed the code, and there might be more ins and outs but that's the gist of it.