Back to Devexpress

DxGrid.Attributes Property

blazor-devexpress-dot-blazor-dot-dxgrid-9f4eaf6f.md

latest3.2 KB
Original Source

DxGrid.Attributes Property

Specifies a collection of standard HTML attributes applied to the Grid.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter(CaptureUnmatchedValues = true)]
public IReadOnlyDictionary<string, object> Attributes { get; set; }

Property Value

TypeDescription
IReadOnlyDictionary<String, Object>

A collection of attributes.

|

Remarks

To apply a standard HTML attribute to the Grid, specify the attribute’s name and its value among Grid properties in the markup. If the specified name does not match an existing Grid property name, the component passes the specified value to the Attributes collection.

You can use the Attributes collection to add Grid attributes at runtime.

If you specify CSS classes with both the CssClass property and the class attribute, the Grid combines them in the rendered HTML element.

The following code snippet sets a custom value to the Grid’s title attribute at design time and runtime.

razor
<DxGrid Data="@Data"        
        title="A sample Grid tooltip.">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" /> 
        <DxGridDataColumn FieldName="Forecast" /> 
        <DxGridDataColumn FieldName="CloudCover" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" />
    </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast().ToList();

    }
}
razor
<DxGrid Data="@Data" 
        Attributes="GridAttributes">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" /> 
        <DxGridDataColumn FieldName="Forecast" /> 
        <DxGridDataColumn FieldName="CloudCover" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" />
    </Columns>
</DxGrid>

@code {
    object Data { get; set; }
    Dictionary<string, object> GridAttributes { get; set; } = new();

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast().ToList();
        GridAttributes["title"] = "A sample Grid tooltip.";
    }
}

Implements

Attributes

See Also

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace