GridSelectionColumnHeaderTemplateContext.SelectAllEnabled Property
Returns whether the select all operation is available.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool SelectAllEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Remarks
A selection column contains a checkbox in the header cell if the column’s AllowSelectAll option is enabled. You can define the column’s HeaderTemplate to display custom select elements in the header.
The select all operation can be temporarily unavailable if there are no data rows to select. For instance, this occurs when you bind the Grid to an asynchronous data source (such as a Server Mode data source or GridDevExtremeDataSource). The SelectAllEnabled
context parameter returns false
while the select all operation cannot be performed. Once this operation becomes available, this parameter returns true
.
In the template, use the SelectAllEnabled
parameter to specify the enabled or disabled state for a custom select element. In the same way, you can use the SelectEnabled parameter in the selection column’s CellDisplayTemplate.
@using Microsoft.EntityFrameworkCore
@using DevExpress.Data.Linq
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable
<DxGrid Data="InstantFeedbackSource"
@bind-SelectedDataItems="@SelectedDataItems"
KeyFieldName="ProductId">
<Columns>
<DxGridSelectionColumn>
<HeaderTemplate>
<DxButton Click="() => context.Grid.SelectAllOnPage()" Text="Select All"
RenderStyle="ButtonRenderStyle.Link"
Enabled="context.SelectAllEnabled"/>
</HeaderTemplate>
</DxGridSelectionColumn>
<DxGridDataColumn FieldName="ProductName" />
<DxGridDataColumn FieldName="UnitPrice" />
<DxGridDataColumn FieldName="QuantityPerUnit" />
<DxGridDataColumn FieldName="UnitsInStock" />
</Columns>
</DxGrid>
@code {
EntityInstantFeedbackSource InstantFeedbackSource { get; set; }
NorthwindContext Northwind { get; set; }
IReadOnlyList<object> SelectedDataItems { get; set; }
protected override void OnInitialized() {
Northwind = NorthwindContextFactory.CreateDbContext();
InstantFeedbackSource = new EntityInstantFeedbackSource(e => {
e.KeyExpression = "ProductId";
e.QueryableSource = Northwind.Products;
});
}
public void Dispose() {
InstantFeedbackSource?.Dispose();
Northwind?.Dispose();
}
}