Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Excel like row header with row index
posted

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

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    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.

     

Children