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

Group by SfDataGrid with row autonumber in first column

I have a SfDataGrid, blinded with dataTable. After grouping i need to have a first column with auto-number. The first record in grouping is a 1 row, and next i+1 to end i+n.

Is it possible to bind the autonumber row in a first column without loop the dataTable?

5 Replies

SM Saravanan M Syncfusion Team January 12, 2015 06:25 PM UTC

 Hi Fernando,

Thanks for contacting Syncfusion support,

We have analyzed your query. We can achieve your requirement by Enabling RowHeader when Group the columns also you need to add the style to display the row number on it.  Please refer the below code snippet to achieve your requirement.

Code snippet[C#]:

this.grid.GroupColumnDescriptions.CollectionChanged += GroupColumnDescriptions_CollectionChanged;

if ((sender as GroupColumnDescriptions).Count > 0)

      this.grid.ShowRowHeader = true;

else

      this.grid.ShowRowHeader = false;

We have prepared a sample based on your requirement and you can download it from below location

Sample: SfDataGrid_RowHeader.zip

You can also refer the below documentation link,

Documentation Link: http://help.syncfusion.com/ug/wpf/documents/rowheader.htm

Please let us know if you have any other queries,

Regards,

Saravanan.M




DF Diego Fernando Urabayen January 12, 2015 09:02 PM UTC

Hi. Thanks for your time.

The solution is close to my problem, but I have to restart to 1 in each group. The idea is to have sequential number in each group. I attach a sample.

Regards,

Diego

Attachment: SyncFusion.png_3881b2cc.zip


SM Saravanan M Syncfusion Team January 13, 2015 12:23 PM UTC


Hi Fernando,

Thanks for your update,

We have analyzed your requirement and you could not show the number in GridIndentCell directly .But you can achieve it by workaround. We have prepared a sample based on your requirement and you can download it from below location.

Sample Location: SfDataGrid_Number.zip

Please let us know if you have any other queries,

Regards,

Saravanan.M




DF Diego Fernando Urabayen January 13, 2015 10:58 PM UTC

Hi, the workaround is very good. Is it possible to bind to the column (GridUnBoundColumn maybe) in order to view the numbers in the PrintPreview function? I need to print the sfDataGrid.


DF Diego Fernando Urabayen January 16, 2015 02:14 AM UTC

I'm trying to bind the row number into column in data grid but not working properly.

<syncfusion:GridUnBoundColumn HeaderText="Pos" Expression="{Binding Converter={StaticResource GroupNumber}, ConverterParameter={RelativeSource Self}}">


Can you help me?

Loader.
Live Chat Icon For mobile
Up arrow icon