How to Efficiently Group a Large Volume of Data in Blazor DataGrid
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)BoldSign  (15)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (67)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (920)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (37)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (151)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (41)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (508)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
How to Efficiently Group a Large Volume of Data in Blazor DataGrid

How to Efficiently Group a Large Volume of Data in Blazor DataGrid

Handling a large volume of data in an application usually consumes a lot of memory, slowing down the application. It is challenging to efficiently handle a large amount of data and maintain good performance. In a scenario of grouping large data, grouping itself would consume considerable memory, and performing the grouping over the data would be very complicated. To effectively handle this scenario, our Blazor DataGrid is designed to support lazy load grouping.

Our Syncfusion Blazor DataGrid is a control for displaying data in tabular format. Its rich feature set includes data binding, editing, Excel-like filtering, custom sorting, grouping, row reordering, freezing rows, and more. It can also export data to Excel, CSV, and PDF formats.

In this blog, we will see how to enable the lazy load grouping feature in the Syncfusion Blazor DataGrid to effectively group and load your large volume of data on demand.

What is lazy loading?

Normally, when a user groups data based on a column, all the grouped records are downloaded from the server and rendered in a single request.

But there’s no guarantee that the user will actually view all of the downloaded data. For example, when a user opens an image gallery website and leaves the site after viewing just the first image. Then, the rest of the downloaded images are a waste of memory and bandwidth.

Instead of loading all the data and rendering it in a single request, the concept of lazy loading loads only the required section. It will delay loading the remaining data until the user needs it.

The advantages of lazy loading are:

  • Reduced initial loading time.
  • Bandwidth conservation.
  • System resource conservation.

Normal grouping vs. lazy load grouping

In normal grouping mode, when a user groups a column, the caption rows, and data rows will be rendered in the expanded state. But the data row rendering is limited by the page size. If the data rows exceed the page size, then the grid will render the remaining data rows on the next page.

In lazy load grouping mode, the Blazor DataGrid renders the caption rows in the collapsed state while performing the group action. When expanding a caption row, the DataGrid will fetch the child rows of each caption row from the server and render them in the viewport.

The first level of group caption rows is considered as a page-size count. For example, if the page size value is 7, then only seven group caption rows will be rendered on each page. There is no limit on the data row count inside of these caption rows.

Thus, each group caption row can contain any number of data rows or nested caption rows.

The following table contains the performance metrics of our Blazor Grid grouping 100k records with and without lazy load option.

Lazy load groupingNormal grouping
Load time when grouping 100k records2 seconds108 seconds

Note: The caption row expand/collapse state persists on each page and the grid page count is based on the caption and child rows.

How to enable lazy load grouping in Syncfusion Blazor DataGrid

Follow these steps to enable the lazy load grouping in the Blazor DataGrid to effectively group a large volume of data. Here, we have loaded up to 100k records in our Blazor DataGrid:

Step 1: Set up Blazor DataGrid

Refer to the Getting Started with Blazor DataGrid documentation to create a Blazor project and add the DataGrid component to your application.

Step 2: Enable lazy load group in the Blazor DataGrid

Then, enable the lazy load grouping feature by setting the EnableLazyLoading property to true in the GridGroupSettings component. Lazy load grouping depends on the grouping feature, so we should set the AllowGrouping property to true.

Refer to the following code example.

<SfGrid TValue="Order" DataSource="Products" AllowGrouping="true" AllowPaging="true" AllowSorting="true" Height="450">
	<GridGroupSettings EnableLazyLoading="true" ShowGroupedColumn="true" Columns="@GroupedColumns">
		<CaptionTemplate>
			@{
				var order = (context as CaptionTemplateContext);
   				<div>@order.HeaderText: @order.Key</div>
			}
		</CaptionTemplate>
	</GridGroupSettings>
	<GridPageSettings PageSize="80"></GridPageSettings>
	<GridAggregates>
		<GridAggregate>
			<GridAggregateColumns>
				<GridAggregateColumn Field=@nameof(Order.UnitsInStock) Type="AggregateType.Sum">
					<GroupFooterTemplate>
						@{
							var Unit = (context as AggregateTemplateContext);
	  						<div>
	   						Total units: @Unit.Sum
	  						</div>
						}
					</GroupFooterTemplate>
				</GridAggregateColumn>
			</GridAggregateColumns>
		</GridAggregate>
	</GridAggregates>
	<GridColumns>
		<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" AllowGrouping="false" TextAlign="@TextAlign.Center" Width="180"></GridColumn>
		<GridColumn Field=@nameof(Order.ProductName) HeaderText="Product" Width="200"></GridColumn>
		<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="170"></GridColumn>
		<GridColumn Field=@nameof(Order.UnitsInStock) HeaderText="Units In Stock" TextAlign="TextAlign.Right" Width="120"></GridColumn>
	</GridColumns>
</SfGrid>

@code {
	public string[] GroupedColumns = new string[] { "ProductName", "CustomerID" };

	public List<Order> Products { get; set; }

	protected override void OnInitialized()
	{
		Products = Order.GetAllRecords();
	}
       
       public class Order
	{
		public int OrderID { get; set; }
		public string CustomerID { get; set; }
		public string CustomerName { get; set; }
		public string CustomerAddress { get; set; }
		public string ProductName { get; set; }
		public int ProductID { get; set; }
		public string Quantity { get; set; }
		public int UnitsInStock { get; set; }
              public static List<Order> GetAllRecords()
		{
			List<Order> customers = new List<Order>();
			. . . . .
                      // code excluded for brevity
			return customers;
		}
	}
}

After executing this code, we will get the output like the following .gif image.

Lazy Load Grouping in Blazor DataGrid
Lazy Load Grouping in Blazor DataGrid

GitHub reference

For more details, refer to the demo to Group Large Data in Blazor DataGrid.

Conclusion

Thanks for reading! In this blog post, we have seen how to effectively group a large amount of data using the lazy load grouping feature in the Syncfusion Blazor DataGrid. You can use this feature to load a huge amount of grouped data in the Grid without any performance degradation. This feature will reduce the initial loading time and enhance the bandwidth and system resource conservation.  We encourage you to go through our Blazor DataGrid demos and documentation for more details. So, try out this feature and leave your feedback in the comments section of this blog post!

The Syncfusion DataGrid component is also available for the ASP.NET (CoreMVCWeb Forms), AngularBlazorReactVueXamarinFlutterUWPWinFormsWPF, and WinUI platforms.

If you aren’t a customer yet, you can try our 30-day free trial to check out the DataGrid and hundreds of other components.

You can also contact us through our support forumDirect-Trac, or feedback portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed