Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (150).NET Core  (25)Angular  (48)ASP.NET  (48)ASP.NET Core  (64)ASP.NET MVC  (86)Azure  (28)Blazor  (91)DocIO  (20)Essential JS 2  (69)Essential Studio  (162)File Formats  (18)Flutter  (102)JavaScript  (148)Microsoft  (101)PDF  (59)React  (33)Succinctly series  (122)Syncfusion  (472)TypeScript  (30)Uno Platform  (3)UWP  (4)Vue  (26)Webinar  (24)Windows Forms  (55)WinUI  (16)WPF  (119)Xamarin  (127)XlsIO  (24)Other CategoriesBarcode  (4)BI  (29)Bold BI  (3)Build conference  (6)Business intelligence  (53)Button  (4)C#  (107)Chart  (50)Cloud  (9)Company  (445)Dashboard  (6)Data Science  (3)Data Validation  (5)DataGrid  (45)Development  (252)Doc  (7)DockingManager  (1)eBook  (93)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (20)Extensions  (13)File Manager  (4)Gantt  (9)Gauge  (6)Git  (4)Grid  (27)HTML  (9)Installer  (2)Knockout  (2)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (214)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (22)Performance  (6)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (5)Road Map  (9)Scheduler  (26)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (18)Solution Services  (2)Spreadsheet  (9)SQL  (7)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (10)Tips and Tricks  (57)UI  (117)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (1)Visual Studio  (19)Visual Studio Code  (10)Web  (205)What's new  (125)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
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:

Share on twitter
Share on facebook
Share on linkedin
Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top