Skip to main content
All docs
V24.1

InputDevice Enum

Lists input devices.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public enum InputDevice

Members

Name Description
Pointer

A pointing device.

Keyboard

A keyboard.

Related API Members

The following properties accept/return InputDevice values:

Remarks

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