Skip to content

Commit ebaf57d

Browse files
ES-975464 - Resolve the ReadMe issue in this sample repository
1 parent dc20277 commit ebaf57d

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# How to hide the detailsview expander icon based on child records count in winui datagrid?
2-
This example describes how to hide the detailsview expander icon based on child records count in winui datagrid.
1+
# How to hide the detailsview expander icon based on child records count in WinUI DataGrid
2+
3+
This example describes how to hide the detailsview expander icon based on child records count in [WinUI DataGrid](https://www.syncfusion.com/winui-controls/datagrid) (SfDataGrid).
4+
5+
By default, the state of expander icon is visible for all the data rows in parent DataGrid even if its `RelationalColumn` property has an empty collection or null.
6+
7+
You can customize hiding the details view expander icon by handling the `SfDataGrid.QueryDetailsViewExpanderState` event. This event occurs when expander icon is changed on expanding or collapsing the details view. You can hide the expander icon by setting the `ExpanderVisibility` property to `false` in the `SfDataGrid.QueryDetailsViewExpanderState` event based on condition.
8+
9+
``` csharp
10+
dataGrid.DetailsViewExpanding += DataGrid_DetailsViewExpanding;
11+
dataGrid.QueryDetailsViewExpanderState += DataGrid_QueryDetailsViewExpanderState;
12+
13+
private void DataGrid_DetailsViewExpanding(object sender, GridDetailsViewExpandingEventArgs e)
14+
{
15+
var employeeInfo = e.Record as Employee;
16+
if (employeeInfo != null)
17+
{
18+
if (employeeInfo.Sales.Count == 0)
19+
e.Cancel = true;
20+
}
21+
}
22+
23+
private void DataGrid_QueryDetailsViewExpanderState(object sender, QueryDetailsViewExpanderStateEventArgs e)
24+
{
25+
var employeeInfo = e.Record as Employee;
26+
if (employeeInfo != null)
27+
{
28+
if (employeeInfo.Sales.Count == 0)
29+
{
30+
e.ExpanderVisibility = false;
31+
}
32+
}
33+
}
34+
```
35+
36+
The following screenshot illustrates hiding expander icon state based on child items count.
37+
38+
![hide the detailsview expander](hide_the_detailsview_expander_icon.png)
27 KB
Loading

0 commit comments

Comments
 (0)