Grid.Blazor icon indicating copy to clipboard operation
Grid.Blazor copied to clipboard

Setup column grouping programmatically

Open dharmatech opened this issue 3 years ago • 3 comments

Example

Here's a grid where I've grouped by Date and Time:

image

The code I used in my Razor Pages page model to turn on grouping:

var server = new GridServer<FoodRecord>(FoodRecord, Request.Query, false, "abcGrid", columns);

grid = server.Grid;

server.Groupable(true);

Question

I'd like to always group by Date and Time, without the user having to drag the columns into the grouping field manually.

Is there a way to group by certain columns programmatically?

dharmatech avatar Jun 05 '21 21:06 dharmatech

Same question here, i want to group by default some columns. Is there a way to do this?

Bonus: i'd like to be able to group but without the possibility to change the default grouping for the user.

@dharmatech Did you find how to achieve this?

Thanks.

cportet-simpleter avatar Jul 23 '21 12:07 cportet-simpleter

Has anyone found any information on grouping programatically? I've tried studying the code examples but I can't find anything that would explain how to group programatically. We don't want to use the drag and drop box, but rather want columns set to group during initialization/rendering. The only documentation seems to be calling the GroupAble() method on the Grid class, nothing about how individual columns are grouped.

rlebowitz avatar Sep 20 '21 17:09 rlebowitz

Checkout OnAfterRenderAsync in ../GridBlazorStandalone/Pages/Groupable.razor

protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { var payloads = new List<ColumnOrderValue>(); payloads.Add(new ColumnOrderValue("Customer.CompanyName", GridSortDirection.Ascending, 1)); payloads.Add(new ColumnOrderValue("ShipVia", GridSortDirection.Ascending, 2)); await _grid.GridComponent.InitGrouping(payloads); } }

SolidDesignCore avatar Oct 17 '22 14:10 SolidDesignCore