Skip to content

Commit 0a97d40

Browse files
Added the changes
1 parent 48e5275 commit 0a97d40

4 files changed

Lines changed: 52 additions & 2 deletions

File tree

DisplayRowIndex.png

60 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Syncfusion.Data.WPF" version="24.1.29" targetFramework="net46" />
4+
<package id="Syncfusion.Licensing" version="23.2.5" targetFramework="net46" />
5+
<package id="Syncfusion.SfGrid.WPF" version="23.2.5" targetFramework="net46" />
6+
<package id="Syncfusion.Shared.WPF" version="23.2.5" targetFramework="net46" />
7+
</packages>

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# How-to-display-the-RowIndex-in-RowHeaderCell-with-SfDatapager-in-WPF-DataGrid-SfDataGrid-
2-
How to to display the RowIndex in GridRowHeaderCell when combined with SfDatapager in WPF DataGrid(SfDataGrid)
1+
# How to to display the RowIndex in GridRowHeaderCell when combined with SfDatapager in WPF DataGrid
2+
3+
You can display the row index value in the RowHeaderCell by customizing its style with the binding of **RowIndex** to the **TextBlock**.**Text** property, as shown in the link below:
4+
5+
[Display RowIndex at RowHeaderCell](https://support.syncfusion.com/kb/article/5182/how-to-display-rowindex-at-rowheadercell-in-sfdatagrid-in-wpf-)
6+
7+
Currently, we do not have direct support to display the number of data in the GridRowHeaderCell when combined with SfDataPager. However, you can achieve this functionality by using a MultivalueConverter and handling the PageIndexChanged event in SfDataPager, as demonstrated below:
8+
9+
```C#
10+
11+
private void SfDataPager_PageIndexChanged(object sender, PageIndexChangedEventArgs e)
12+
{
13+
for (int i = 1; i &lt; dataGrid.RowGenerator.Items.Count; i++)
14+
{
15+
var rowHeaderCell = ((dataGrid.RowGenerator.Items[i] as DataRow).VisibleColumns[0] as DataColumn).ColumnElement;
16+
(rowHeaderCell as GridRowHeaderCell).RowIndex = -1;
17+
}
18+
}
19+
20+
```
21+
22+
```C#
23+
24+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
25+
{
26+
var dataPager = values[2] as SfDataPager;
27+
28+
if (dataPager.PageIndex == 0 || (int)values[0] == -1)
29+
{
30+
return values[0].ToString();
31+
}
32+
33+
values[0] = (int)values[0] + (((dataPager.PageIndex + 1) - 1) * dataPager.PageSize);
34+
return values[0].ToString();
35+
36+
}
37+
38+
```
39+
40+
The index is displayed in RowHeaderCell based on the above customized style like below,
41+
![Shows the RowIndex](DisplayRowIndex.png)
42+
43+
![Shows the secondpage RowIndex](SecondPageDisplayRowIndex.png)
44+
45+
Take a moment to peruse the [WPF DataGrid - Row Header](https://help.syncfusion.com/wpf/datagrid/rows#row-header) documentation, to learn more about Row Header code examples.

SecondPageDisplayRowIndex.png

58.9 KB
Loading

0 commit comments

Comments
 (0)