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
Thank you! That is exactly what I was looking for!
/D
Hi David,
I think you are right and that I misunderstood the question. Your mention of Excel made me think you were exporting the grid to Excel and wanted to export row numbers there.
But after re-reading your post, it looks like you just want to show row numbers in the grid on the screen.
That's a lot easier. The code looks something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.RowSelectors = DefaultableBoolean.True; e.Layout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.VisibleIndex; }
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...
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.