/* ------------ DataGrid mouse event processing ------------
Function: used for mouse events after data is sorted
Parameter description:
OBJ: object like this
Fontcolor: font color
Backcolor: Background Color
----------------------------------------------*/
VaR objstate
-----------
Function onfoucsmouseover (OBJ, fontcolor, backcolor)
{
If (obj. rowindex> 0)
{
OBJ. style. Color = fontcolor;
OBJ. style. backgroundcolor = backcolor;
}
}
// ----------- --------- When the mouse leaves -----------
Function onfoucsmouseout (OBJ, fontcolor, backcolor)
{
If (obj. rowindex> 0)
{
If (OBJ! = Objstate)
{
OBJ. style. Color = fontcolor;
OBJ. style. backgroundcolor = backcolor;
}
}
}
-----------
Function onfoucsclick (OBJ, fontcolor, backcolor)
{
If (obj. rowindex> 0)
{
If (objstate! = NULL)
{
Objstate. style. color = "";
Objstate. style. backgroundcolor = "";
}
OBJ. style. Color = fontcolor;
OBJ. style. backgroundcolor = backcolor;
Objstate = OBJ;
}
}
-----------
Function onfoucsdbclick (OBJ, fontcolor, backcolor, Openurl)
{
// The Openurl parameter is the address of the new window to be opened.
If (obj. rowindex> 0)
{
If (objstate! = NULL)
{
Objstate. style. color = "";
Objstate. style. backgroundcolor = "";
}
OBJ. style. Color = fontcolor;
OBJ. style. backgroundcolor = backcolor;
Objstate = OBJ;
Window. Open (Openurl );
}
}
========================================================== =
The following is an example of backend data partitioning:
========================================================== =
Private void dglist_itemdatabound (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
//
If (E. Item. itemindex! =-1)
{
E. Item. Attributes. Add ("onmouseover", "onfoucsmouseover (this, '# ffff',' #000000 ');");
E. Item. Attributes. Add ("onmouseout", "onfoucsmouseout (this, '#000000', '# ffff ');");
E. Item. Attributes. Add ("onclick", "onfoucsclick (this, '# ffff',' #000000 ');");
E. Item. Attributes. Add ("ondblclick", "onfoucsdbclick (this, '# ffff',' #000000 ', 'about: Bank ');");
}
}
========================================================== =
The front-end. ASPX page calls the JS file:
<Script language = "JavaScript" src = "gridcontrol. js"> </SCRIPT>