Skip to main content

DxGrid.PopupEditFormCssClass Property

Assign a CSS class to the pop-up edit form.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(null)]
[Parameter]
public string PopupEditFormCssClass { get; set; }

Property Value

Type Default Description
String null

CSS class names delimited by spaces.

Remarks

The Grid displays the edit form in a pop-up window if the EditMode property is set to GridEditMode.PopupEditForm. In this mode, you can assign a CSS class name to the PopupEditFormCssClass property to customize edit form appearance. You can also use the PopupEditFormHeaderText option to specify text displayed in the form header.

Tip

For information on how to enable data editing and use edit-related options, refer to the following topic: Editing and Validation in Blazor Grid.

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

<style>
    .my-style {
        min-width: 800px;
    }
</style>

<DxGrid Data="GridDataSource"
        EditModelSaving="OnEditModelSaving"
        DataItemDeleting="OnDataItemDeleting"
        KeyFieldName="EmployeeId"
        EditMode="GridEditMode.PopupEditForm"
        PopupEditFormHeaderText="Edit Employee"
        PopupEditFormCssClass="my-style">
    <Columns>
        <DxGridCommandColumn />
        <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<object> GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override async Task OnInitializedAsync() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = await Northwind.Employees.ToListAsync();
    }

    async Task OnEditModelSaving(GridEditModelSavingEventArgs e) {
        var editModel = (Employee)e.EditModel;
        if (e.IsNew)
            await Northwind.AddAsync(editModel);
        else
            e.CopyChangesToDataItem();
        // Post changes to the database.
        await Northwind.SaveChangesAsync();
        // Reload the entire Grid.
        GridDataSource = await Northwind.Employees.ToListAsync();
    }

    async Task OnDataItemDeleting(GridDataItemDeletingEventArgs e) {
        // Remove the data item from the database.
        Northwind.Remove(e.DataItem);
        await Northwind.SaveChangesAsync();
        // Reload the entire Grid.
        GridDataSource = await Northwind.Employees.ToListAsync();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

Blazor Grid Popup Edit Form

For more information on how to apply CSS classes to DevExpress Blazor components, refer to the following help topic: CSS Classes.

If your custom CSS ruleset includes only one class selector (.my-style in the code sample above), some property declarations can be ignored. DevExpress themes can apply predefined CSS rules that are more specific and have higher priority than a single-selector rule. Make your rule more specific to increase the priority of your ruleset. See the following help topic for an example: Apply Styles to Components. For more information about how a browser calculates rule priority, refer to the following topic: Understanding the cascade.

You can use the !important flag to override other CSS rules. However, note that this flag modifies the standard behavior of the cascade, which can make troubleshooting CSS issues quite challenging, particularly in large stylesheets.

See Also