I use Grid 18.1.0.42 in a very simple app to see how to handle large dataset. The datasource is an IQueryable return from EF.
From the console logger, I see 5 queries appear while the Grid showing data. Will it affect the performance? Can I have a sample to use Grid with large datasource.
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url].......
Once I click paging number, I see only query:
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (2ms) [Parameters=[@__p_0='24', @__p_1='12'], CommandType='Text', CommandTimeout='30']
SELECT [o].[ordi_id], [o].[barcode_url], .........
FROM [OrderItems] AS [o]
ORDER BY (SELECT 1)
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
In my data service, I use:
public class MugPrintService : IMugPrintService
{
private readonly MugPrintDbContext _context;
public MugPrintService(MugPrintDbContext context)
{
_context = context;
}
public IQueryable<OrderItem> GetOrders()
{
return
_context.OrderItems;
}
}
In blazor page:
<SfGrid DataSource="@orders" AllowGrouping="true" AllowPaging="true" AllowFiltering="true" AllowSelection="true" Toolbar="@(new List<string>() { "Search"})">
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>
<GridColumns>
<GridColumn Field="ordi_id" HeaderText="ordi_id" Type="ColumnType.String"></GridColumn>
<GridColumn Field="ord_id" HeaderText="ord_id" Type="ColumnType.Number"></GridColumn>
<GridColumn Field="product_id" HeaderText="product_id" Type="ColumnType.Number"></GridColumn>
<GridColumn Field="bin_id" HeaderText="bin_id" Type="ColumnType.String"></GridColumn>
<GridColumn Field="ord_approve_date" HeaderText="ord_approve_date" Type="ColumnType.DateTime"></GridColumn>
<GridColumn Field="is_fastship" HeaderText="is_fastship" Type="ColumnType.Number"></GridColumn>
<GridColumn Field="color" HeaderText="color" Type="ColumnType.String"></GridColumn>
<GridColumn Field="size" HeaderText="size" Type="ColumnType.String"></GridColumn>
<GridColumn Field="side_print" HeaderText="side_print" Type="ColumnType.String"></GridColumn>
<GridColumn Field="server_status" HeaderText="server_status" Type="ColumnType.String"></GridColumn>
</GridColumns>
</SfGrid>
@code {
private IQueryable<OrderItem> orders;
protected override void OnInitialized()
{
orders = MugPrintService.GetOrders();
}
}