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

GridDataControl display row numbers

Hi, I am using GridDataControl WPF control and binding data to the view using mvvm. How can i display row numbers in the grid ? is there a built in functionality to do that ? Basically i want to display the sequence numbers for each row in the grid.

Thanks
Raghu

1 Reply

DA Divya A Syncfusion Team April 25, 2013 10:00 AM UTC

Hi Raghu,

 

Thanks for using Syncfusion products.

 

We have analyzed your query, you can achieve your requirement by enabling ShowRowHeader API as true and you can set the row numbers in the row header by handling QueryCellInfo event. You can handle event inside a Behavior in MVVM pattern.

 

 

Code Snippet:

 

     <syncfusion:GridDataControl x:Name="SyncGrid"

                                    AutoPopulateColumns="True"

                                    ItemsSource="{StaticResource ComboSource}"

                                    ShowAddNewRow="False"

                                    ShowFilterBar="True"

                                    ShowRowHeader="True">

            <I:Interaction.Behaviors>

                <local:QueryCellInfoBehavior/>

            </I:Interaction.Behaviors>

    </syncfusion:GridDataControl>

 

 

    GDC.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);

 

 

        void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

        {

            var style = e.Style as GridDataStyleInfo;

 

            if (style.CellIdentity.TableCellType == GridDataTableCellType.RowHeaderCell)

            {

                e.Style.CellValue = e.Style.CellRowColumnIndex.RowIndex;

            }

        }

 

 

 

We have prepared a sample based on your requirement and attached it in the following location.

 

Sample: GridDataControlSample.zip

 

Regards,

Divya.


Loader.
Live Chat Icon For mobile
Up arrow icon