Autonumerate rows except "masterdetailview" rows

Hello

I'am using SfDataGrid with Master Details View. How to autonumerate only "main" rows? I don't want to involve nested tables rows in rows autonumeration . Is that possible?


7 Replies

MA Mohanram Anbukkarasu Syncfusion Team August 19, 2021 06:00 AM UTC

Hi James, 

Thanks for contacting Syncfusion products.  

You can achieve your requirement to cancel autogenerating the relations by disabling SfDataGrid.AutoGenerateRelations property.  

Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 



JA James August 19, 2021 07:40 AM UTC

I've set AutogenerateRelations to false, but that doesn't solve my problem.


I use style to autonumerate rows


and i get:

2021-08-19_09h31_34.png


But i want to autonumerate only "main" rows and get

Bez tytułu.jpg



MA Mohanram Anbukkarasu Syncfusion Team August 19, 2021 08:12 AM UTC

Hi James, 

Thanks for the update.  

Please set AutoGenerateRelations to false before binding the ItemsSource for the SfDataGrid as shown in the following code example.  

Code example :  

<syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumns="True" AutoGenerateRelations="False" ItemsSource="{Binding Employees}"> 

Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 



JA James August 19, 2021 08:36 AM UTC

Nothing changed. Maybe the probelem is in style i use for set row number in header:


<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>



MA Mohanram Anbukkarasu Syncfusion Team August 20, 2021 08:51 AM UTC

Hi James, 

Thanks for the update.  

We would like to let you know that the style for row header will not be the cause for the issue. We have prepared a simple sample using DetaisView and RowHeader style. AutoGenerateRelations property works properly in it.  


Please have a look at this sample and let us know if we have missed any customization you have done in your application. Otherwise try to reproduce the reported issue in this sample and revert to us with the modified sample. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution at earlier. 

Regards, 
Mohanram A. 



JA James replied to Mohanram Anbukkarasu August 20, 2021 06:53 PM UTC

Your sample shows autonumerate all rows in datagrid. And style is responsible for this numeration. When you add  Master Detail View, the detail View rows will be autonumerate as well.  I need a solution for autonumerating only Master rows without Details rows :-) thus i thought it might be achieve by modyfying style which now affected all rows. Maybe exclude detail rows  in the style code help to solve my problem 



BT Balamurugan Thirumalaikumar Syncfusion Team August 23, 2021 01:31 PM UTC

Hi James, 
 
Thank you for the update. 
 
We have checked your previous update from our end. We would like to let you know that AutoGenerateRelations will not be affected by changing the style. Please check our provided sample and modify it to recreate the reported scenario if possible. This will allow us to check further and provide you with the most expedient solution. 
 
Regards 
Balamurugan.Thirumalaikumar 


Loader.
Up arrow icon