Hi,
Is there an Excel like row header where I can display row index regardless of sort and filtering? I tried adding a column with row.visibleIndex but then the data would have to be added after sort and it seems a bit awkward. Furthermore I would like the row index column to NOT be part of the grid data so I wouldn't have to filter it out when exporting etc.
Thanks, David
Hi David,
There are a couple of ways you could do this. I would probably use the CellExporting event of the UltraGridRowExporter. This event (and most of the events on the component) passes you the CurrentRowIndex and CurrencyColumnIndex, which are settable.
So one way you could do this would be to handle events like CellExporting and watch for the exporting of the first visible cell in the row, then increment the CurrentColumnIndex by 1. This would have the effect of shifting the entire row over by one column. You could then write anything you want into the current cell, such as a numeric index or e.GridRow.VisibleIndex.
You would have to do the same thing in HeaderExporting, of course, to shift the headers over to match the columns.
Another option would be to add an unbound column to the grid and populate it in the InitializeRow event. You don't want this column to show up on-screen, so you could either hide it or not add it to the actual grid. Then you would use the BeginExport event of the ExcelExporter and modify the layout passed into the event. This layout is a clone of the layout of the on-screen grid. So you could make the hdidden column visible in this layout without affecting the on-screen grid, or even add a new unbound column ot the layout here.
Thanks for the quick response!
I'm not sure that I understand your suggestion though, and to make sure that I know, that you know what I'm looking for, I'll try to ask my question again. Bear with me, English is not my mother tounge.
The circled area is what I'm looking for. A part of the grid but not really a part of the data source. I thought that this sort of thing would be built into UltraGrid as I imagine a lot of people need it. I'm still hoping that it is and just want to check with you before I build my own...