Datagrid with custom adapter collapse grouping by defalt
The only way I could get a DataGrid with customdata adapter that has an initial group to be collapsed is using
EnableVirtualization="true". Is there a way to get all the data loaded and have the group collapsed
Here is my grid code
<SfGrid TValue="TimeEntry" @ref="Grid" AllowSorting="true" AllowFiltering="true" AllowGrouping="true"
AllowPaging="true" Toolbar=@Toolbaritems Query="@Query"
RowHeight="25">
<GridGroupSettings Columns="@this.IntitGroup" ></GridGroupSettings>
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor" ></SfDataManager>
Hi Lonny,
Greetings from Syncfusion.
Query: “The only way I could get a DataGrid with customdata adapter that has an initial group to be collapsed is using
EnableVirtualization="true". Is there a way to get all the data loaded and have the group collapsed ”
We suggest you try using CollapseAllGroupAsync inside the DataBound event to collapse all the grouped rows in DataGrid. We have prepared a simple sample. Kindly check the below attached sample and code snippet for your reference.
|
<SfGrid TValue="Order" ID="Grid" @ref="Grid" AllowGrouping="true" EnableVirtualization="false" Width="500" Height="500"> <SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager> <GridPageSettings PageSize="50"></GridPageSettings> <GridEvents DataBound="DataBound" TValue="Order"></GridEvents> <GridGroupSettings Columns="@Initial"></GridGroupSettings> <GridColumns> </GridColumns> </SfGrid>
@code { public static List<Order> Orders { get; set; } public SfGrid<Order> Grid { get; set; } public string[] Initial = (new string[] { "OrderID" }); public async void DataBound() { await Grid.CollapseAllGroupAsync(); } |
Kindly get back to us if you have further queries.
Regards,
Monisha
It never hits the Databound event Here is me code for the grid and @code section
<SfGrid TValue="TimeEntry" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowGrouping="true"
AllowPaging="true" Toolbar=@Toolbaritems Query="@Query" EnableVirtualization="false"
RowHeight="25">
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
<GridEvents DataBound="DataBound" TValue="TimeEntry"></GridEvents>
<GridGroupSettings Columns="@this.IntitGroup" ></GridGroupSettings>
@code {
[Parameter]
public string Entity { get; set; }
[Parameter]
public List<Object> Toolbaritems { get; set; }
[Parameter]
public Query Query { get; set; }
[Parameter]
public string[] IntitGroup { get; set; }
SfGrid<TimeEntry> Grid;
public string message;
private bool initial { get; set; }
protected override void OnParametersSet()
{
if(IntitGroup.Count() > 0)
{
initial = true;
}
}
public async void DataBound()
{
await Grid.CollapseAllGroupAsync();
}
Needed to add ID="GRID" and @ref="Grid" which was missing from my grid.
We are unable to reproduce the reported issue when
attempting to reproduce the issue in the latest version 27.1.53 . For
your reference we have attached a simple sample .So, to
further
proceed with the reporting problem, we require some additional clarification
from your end. Please share the below details to proceed further at our end.
- To analyze the reported issue, could you please share a simple and reproducible sample that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.
- If possible, kindly share your attempt to replicate the issue using the attached simple sample.
Above-requested details will be very helpful in validating the reported query at our end and providing a solution as early as possible. Thanks for your understanding.
Additionally, we would like to clarify that when using the grid instance, you need to reference the SfGrid. Kindly refer to the code snippet below for your reference.
|
<SfGrid TValue="Order" ID="Grid" @ref="Grid" AllowGrouping="true" EnableVirtualization="false" Width="500" Height="500"> </SfGrid>
|
- 4 Replies
- 3 Participants
- Marked answer
-
LB Lonny Blank
- Oct 14, 2024 11:26 PM UTC
- Oct 16, 2024 09:31 AM UTC