Skip to main content
All docs
V24.1

GridRowClickEventArgs.InputDevice Property

Returns the input device that triggered the event.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public InputDevice InputDevice { get; }

Property Value

Type Description
InputDevice

The input device that triggered the event.

Available values:

Name Description
Pointer

A pointing device.

Keyboard

A keyboard.

Remarks

The Grid component raises the RowClick event in response to the following actions:

  • A user clicks a data or group row with a pointing device.
  • A user focuses a data cell in display mode and presses Enter.

Use the InputDevice event argument to determine which action triggered the RowClick event. For the RowDoubleClick event, the InputDevice property always returns Pointer.

The following example switches the Grid to edit mode when a user double-clicks a row or focuses a row and presses Enter:

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="Data"
        RowClick="OnRowClick"
        RowDoubleClick="OnRowDoubleClick"
        EditModelSaving="OnEditModelSaving"
        DataItemDeleting="OnDataItemDeleting"
        KeyFieldName="EmployeeId">
    <Columns>
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="Title" />
        <DxGridDataColumn FieldName="HireDate" />
    </Columns>
    <EditFormTemplate Context="editFormContext">
        <DxFormLayout>
            <DxFormLayoutItem Caption="First Name:">
                @editFormContext.GetEditor("FirstName")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Last Name:">
                @editFormContext.GetEditor("LastName")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Title:">
                @editFormContext.GetEditor("Title")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Hire Date:">
                @editFormContext.GetEditor("HireDate")
            </DxFormLayoutItem>
        </DxFormLayout>
    </EditFormTemplate>
</DxGrid>

@code {
    IEnumerable<Employee> Data { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override async Task OnInitializedAsync() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = await Northwind.Employees.ToListAsync();
    }
    void OnRowDoubleClick(GridRowClickEventArgs e) { 
        e.Grid.StartEditRowAsync(e.VisibleIndex);
    }
    void OnRowClick(GridRowClickEventArgs e) { 
        if (e.InputDevice == InputDevice.Keyboard)
            e.Grid.StartEditRowAsync(e.VisibleIndex);
    }
    async Task OnEditModelSaving(GridEditModelSavingEventArgs e) {
        var editModel = (Employee)e.EditModel;
        if (e.IsNew)
            await Northwind.AddAsync(editModel);
        else
            e.CopyChangesToDataItem();
        await Northwind.SaveChangesAsync();
        Data = await Northwind.Employees.ToListAsync();
    }
    async Task OnDataItemDeleting(GridDataItemDeletingEventArgs e) {
        Northwind.Remove(e.DataItem);
        await Northwind.SaveChangesAsync();
        Data = await Northwind.Employees.ToListAsync();
    }
    public void Dispose() {
        Northwind?.Dispose();
    }
}
See Also