Several events of the GridView (for example, double-click the row, click/capture the keyboard buttons, hover the mouse, and remove the row) (sample code download)

Source: Internet
Author: User

Several events of the GridView (for example, double-click the row, click/capture the keyboard buttons, hover the mouse, and remove the row) (sample code download)

(1). Example Image

 

(2). Code

[Front-end]

<Script language = "javascript">
Function DbClickEvent (d)
{
Window. alert ("Event Type: DoubleClidk:" + d );
}
Function ClickEvent (d)
{
Window. alert ("Event Type: OnClick object:" + d );
}
Function GridViewItemKeyDownEvent (d)
{
Window. alert ("Event Type: GridViewItemKeyDownEvent:" + d );
}
Function KeyDownEvent ()
{
If (event. altKey & event. keyCode> 48 & event. keyCode <54)
{
Window. alert ("event Type: FormKeyDownEvent selected records:" + (parseInt (event. keyCode)-48 ));
}
}
</Script>

[Background]

If (e. Row. RowType = DataControlRowType. DataRow)
{
// The effect of alternating colors when the mouse moves to each item
E. Row. Attributes. Add ("OnMouseOut", "this. style. backgroundColor = 'white'; this. style. color = '#003399 '");
E. Row. Attributes. Add ("OnMouseOver", "this. style. backgroundColor = '# 6699FF'; this. style. color = '#8C4510 '");

// Click/double-click the event
E. Row. Attributes. Add ("OnDblClick", "DbClickEvent ('" + e. Row. Cells [1]. Text + "')");
E. Row. Attributes. Add ("OnClick", "ClickEvent ('" + e. Row. Cells [1]. Text + "')");

E. Row. Attributes. Add ("OnKeyDown", "GridViewItemKeyDownEvent ('" + e. Row. Cells [1]. Text + "')");

// Set the floating mouse pointer to "hand"
E. Row. Attributes ["style"] = "Cursor: hand ";

}

* There are more and more events. You can use similar methods to complete more complex and better-performing pages.

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.