The completion function is used to change the tr color of the selected event, mouse event, and double-click event on the page of the DataGrid.

Source: Internet
Author: User
/* ------------ 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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.