BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hello.
Hi Vladimir,
Thank you for using Syncfusion products.
We have analyzed your query. You can show the row number in RowHeader by write the style for GridRowHeaderCell and bind the RowIndex.
Code Example [XAML]:
<Style TargetType="Syncfusion:GridRowHeaderCell"> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Gray" /> <Setter Property="BorderThickness" Value="0,0,1,1" /> <Setter Property="Padding" Value="0,0,0,0" /> <Setter Property="FontFamily" Value=" Segoe UI" /> <Setter Property="FontSize" Value="12" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Syncfusion:GridRowHeaderCell"> <Border x:Name="PART_RowHeaderCellBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <Grid> <TextBlock Text="{Binding RowIndex, RelativeSource={RelativeSource TemplatedParent}}"/> </Grid> </Border>
</ControlTemplate> </Setter.Value> </Setter> </Style> |
We have also prepared the sample based on this and you can download the sample from the below location,
Sample: http://www.syncfusion.com/downloads/support/directtrac/143673/ze/SfGridDemo652568442
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
Hi Vladimir,
Thank you for your update.
StackedHeaderRows collection has the definition for StackedHeaderRow. A Stacked Header Row is viewed as a set of Stacked Columns where each StackedColumn contains a number of Child Columns. Each Stacked Header Row has different RowIndex in SfDataGrid. Please refer the below UG link to get more details regarding StackedHeaderRows in SfDataGrid
UG link: http://docs.syncfusion.com/wpf/sfdatagrid/columns#frozen-columns
Please let us know if you require any further assistance.
Thanks,
Ashok
Yes, I have read this documentation, thank you. :)
I assumed that there is some existing solution, such as an extra field names like DataRowIndex omewhere or some method for this need somewhere in helpers.
Now i solve this with IMultiValueConverter
Template looks like:
<ControlTemplate TargetType="syncfusion:GridRowHeaderCell">
<Border x:Name="PART_RowHeaderCellBorder"
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}">
<Grid>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource RowToIndexConverter}">
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=sfGrid:SfDataGrid}" />
<Binding Path="RowIndex" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</Border>
</ControlTemplate>
And converter looks like:
public class RowToIndexConverter : IMultiValueConverter{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
SfDataGrid sfdatgrid = values.Single(v => v is SfDataGrid) as SfDataGrid;
int rowIndex = (int) values.Single(v => v is int);
object recordRow = sfdatgrid.GetRecordAtRowIndex(rowIndex);
// Only for record rows
if (recordRow != null)
{
rowIndex = rowIndex - sfdatgrid.StackedHeaderRows.Count;
return rowIndex.ToString();
}
return DependencyProperty.UnsetValue;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
This works fine and smells acceptable for me.
Hi Vladimir,
Thank you for using Syncfusion products.
We have analyzed your query. You can show the row number in RowHeader by write the style for GridRowHeaderCell and bind the RowIndex.
Code Example [XAML]:
<Style TargetType="Syncfusion:GridRowHeaderCell">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="FontFamily" Value=" Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Syncfusion:GridRowHeaderCell">
<Border x:Name="PART_RowHeaderCellBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<TextBlock Text="{Binding RowIndex, RelativeSource={RelativeSource TemplatedParent}}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
We have also prepared the sample based on this and you can download the sample from the below location,
Sample: http://www.syncfusion.com/downloads/support/directtrac/143673/ze/SfGridDemo652568442
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
<Style TargetType="Syncfusion:GridRowHeaderIndentCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Syncfusion:GridRowHeaderIndentCell">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" >
<Grid>
<TextBlock Text="{Binding RowHeaderText}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> |