GridSelectionColumnCellDisplayTemplateContext.SelectEnabled Property
Returns whether the select operation is available for a row from an asynchronous data source.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool SelectEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Remarks
A selection column contains checkboxes or radio buttons depending on the selection mode. You can define the column’s CellDisplayTemplate to display custom select elements in column cells that correspond to data rows.
The select operation can be temporarily unavailable if you bind the Grid to an asynchronous data source (such as a Server Mode data source or GridDevExtremeDataSource). The SelectEnabled
context parameter returns false
while the select operation cannot be performed. Once this operation becomes available, this parameter returns true
.
In the template, use the SelectEnabled
parameter to specify the enabled or disabled state for a custom select element. In the same way, you can use the SelectAllEnabled parameter in the selection column’s HeaderTemplate.
@using Microsoft.EntityFrameworkCore
@using DevExpress.Data.Linq
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable
<DxGrid Data="InstantFeedbackSource"
SelectionMode="GridSelectionMode.Single"
@bind-SelectedDataItem="@SelectedDataItem"
KeyFieldName="ProductId">
<Columns>
<DxGridSelectionColumn>
<CellDisplayTemplate >
<DxButton Click="@(() => context.Grid.SelectDataItem(context.DataItem))"
Text="Select" RenderStyle="ButtonRenderStyle.Link"
Enabled="context.SelectEnabled"/>
</CellDisplayTemplate>
</DxGridSelectionColumn>
<DxGridDataColumn FieldName="ProductName" />
<DxGridDataColumn FieldName="UnitPrice" />
<DxGridDataColumn FieldName="QuantityPerUnit" />
<DxGridDataColumn FieldName="UnitsInStock" />
</Columns>
</DxGrid>
@code {
EntityInstantFeedbackSource InstantFeedbackSource { get; set; }
NorthwindContext Northwind { get; set; }
object SelectedDataItem { 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();
}
}