Coder Social home page Coder Social logo

devexpress-examples / asp-net-web-forms-grid-handle-rowclick-and-rowdblclick-events Goto Github PK

View Code? Open in Web Editor NEW
4.0 56.0 1.0 456 KB

Handle the grid's client-side RowClick and RowDblClick events to perform custom operations on single and double row clicks.

License: Other

C# 21.43% ASP.NET 56.79% Visual Basic .NET 21.78%
dotnet aspxgridview asp-net client-side

asp-net-web-forms-grid-handle-rowclick-and-rowdblclick-events's Introduction

Grid View for ASP.NET Web Forms - How to use both the RowClick and RowDoubleClick events.

This example demonstrates how to handle the grid's client-side RowClick and RowDblClick events to perform custom operations on single and double row clicks.

Click

Overview

Follow the steps below:

  1. Create the Grid View control, populate it with columns, and bind the control to a data source. Set the grid's AllowFocusedRow property to true to enable row focus and use the GridViewStyles.FocusedRow property to specify the appearance of the focused row.

    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" KeyFieldName="CategoryID"
        DataSourceID="AccessDataSource1">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1" />
            <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2" />
        </Columns>
        <SettingsBehavior AllowFocusedRow="True" />
        <Styles>
            <FocusedRow BackColor="#C0FFC0" ForeColor="Black" />
        </Styles>
    </dx:ASPxGridView>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
        SelectCommand="SELECT * FROM [Categories]">
    </asp:AccessDataSource>
  2. Add a flag variable and create the ProcessClick function that the grid executes based on the flag variable value. Handle the grid's client-side RowClick and RowDblClick events. In the RowClick event handler, call the setTimeout method to set a timer for the ProcessClick function.

    var doProcessClick;
    var index;
    function ProcessClick() {
        if (doProcessClick) {
            alert(`Here is the RowClick action in the ${index.toString()} row.`);
        }
    }
    function OnRowClick(s, e) {
        doProcessClick = true;
        index = e.visibleIndex + 1;
        window.setTimeout(ProcessClick, 500);
    }
    
    function OnRowDblClick(s, e) {
        doProcessClick = false;
        var key = s.GetRowKey(e.visibleIndex);
        alert(`Here is the RowDoubleClick action in the row with the key = ${key}.`);
    }

Files to Review

Documentation

asp-net-web-forms-grid-handle-rowclick-and-rowdblclick-events's People

Contributors

devexpressexamplebot avatar elenapeskova avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

elenapeskova

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.