We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Alternative of LoadingRow event?

I wanted to handle the LoadingRow  event to make a serial number row header:
     private void Dgrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            e.Row.Header = (e.Row.GetIndex() + 1).ToString();

        }
but I didn't find it or any alike events, is there any Alternative approach?

Thanks in advance.

3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team September 26, 2017 04:03 PM UTC

Hi Mohamed, 

Thank you for contacting Syncfusion support. 

You can achieve your requirement by customizing the style of GridRowHeaderCell as like below code. In that below attached sample, we have displayed the row index in GridRowHeaderCell by binding the row index value in to TextBlock. For your reference, we have attached sample and documentation link as below. Could you please refer to it. 

Code Snippet: Xaml 

<Style TargetType="syncfusion:GridRowHeaderCell"> 
    <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 HorizontalAlignment="Center" 
                                    VerticalAlignment="Center" 
                                    Text="{Binding RowIndex, RelativeSource={RelativeSource TemplatedParent}}" 
                                    TextAlignment="Center" /> 
                    </Grid> 
                </Border> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style> 



For more details about displaying the row index value in row header cell in SfDataGrid, 

Please let us know if you have any other questions. 

Regards, 
Muthukumar K 



MO Mohamed September 27, 2017 07:04 AM UTC

Perfect, thanks.



MK Muthukumar Kalyanasundaram Syncfusion Team September 28, 2017 05:31 AM UTC

Hi Mohamed 

You are welcome. Please let us know if you need any other assistance.               
 
Regards,  
Muthukumar K  


Loader.
Up arrow icon