DxComboBoxSettings.DataLoadMode Property
Specifies how the ComboBox loads its data.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v26.1.dll
Declaration
[DefaultValue(ListDataLoadMode.Auto)]
[Parameter]
public ListDataLoadMode DataLoadMode { get; set; }
Property Value
| Type | Default | Description |
|---|---|---|
| ListDataLoadMode | Auto | A ListDataLoadMode enumeration value. |
Available values:
| Name | Description |
|---|---|
| Auto | The component loads and caches data when the browser loads the web page. Use this mode to improve application responsiveness after initial page load. |
| OnDemand | The component loads its data whenever a user opens the drop-down window. The component does not cache its data. We recommend using this mode if the page contains multiple ComboBox components and they are bound to large data sources (data queries require resource-intensive operations). In this case, OnDemand mode optimizes page load time and resource usage. Since data is not fetched during component initialization, the page loads faster. By not caching data, the component avoids unnecessary memory consumption (in case the user never needs to open the dropdown). |
Remarks
The ComboBox supports two load modes:
Auto(default)- The component loads and caches data when the browser loads the web page. Use this mode to improve application responsiveness after initial page load.
OnDemand- The component loads its data whenever a user opens the drop-down window. The component does not cache its data. We recommend using this mode if the page contains multiple ComboBox components and they are bound to large data sources (data queries require resource-intensive operations). In this case, OnDemand mode optimizes page load time and resource usage. Since data is not fetched during component initialization, the page loads faster. By not caching data, the component avoids unnecessary memory consumption (in case the user never needs to open the dropdown).
Use the DataLoadMode property to switch between modes.
The following code snippet activates the OnDemand data loading mode in a combobox editor:
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
<DxGrid Data="Orders"
EditMode="GridEditMode.EditRow">
<Columns>
<DxGridCommandColumn />
<DxGridDataColumn FieldName="EmployeeId" Caption="Employee" Width="20%">
<EditSettings>
<DxComboBoxSettings Data="Employees"
TextFieldName="LastName"
ValueFieldName="EmployeeId"
DataLoadMode="DataLoadMode.OnDemand">
</DxComboBoxSettings>
</EditSettings>
</DxGridDataColumn>
<DxGridDataColumn FieldName="ShippedDate" />
<DxGridDataColumn FieldName="ShipCountry" />
<DxGridDataColumn FieldName="ShipCity" />
<DxGridDataColumn FieldName="ShipName" Width="20%" />
</Columns>
</DxGrid>
@code {
NorthwindContext Northwind { get; set; }
List<Order> Orders { get; set; }
List<Employee> Employees { get; set; }
protected override async Task OnInitializedAsync() {
Northwind = NorthwindContextFactory.CreateDbContext();
Orders = await Northwind.Orders.ToListAsync();
Employees = await Northwind.Employees.ToListAsync();
}
public void Dispose() {
Northwind?.Dispose();
}
}
To specify data load mode in a combo box at runtime, use the IComboBoxSettings.DataLoadMode property.
Virtual Scrolling Limitations
When you activate both OnDemand load mode and virtual scrolling (ListRenderMode is set to Virtual), the following limitations apply:
- If the selected item is outside the viewport, the component may not scroll to it when the user opens the drop-down list.
- If the component uses different
TDataandTValuetypes, the component may display the selected item’s text incorrectly on a page load. For example, you have a list of 100 items. The selected item is Item 50. Since the component loads only 20 items initially, the item’s text can not be found and displayed correctly. Only when a user opens the drop-down list, the selected item’s text will be displayed.