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
20
Limiting the number of rows in UltraWinGrid
posted

Hi all,

I have a grid that should only show the top 5 rows. However, the data has more than 5 rows and there maybe occasions where I need to sort the grid with all the data, but just show the top 5 rows after sorting.

Is there a feature inUltraWinGrid that would allow me to do that?

If so, could you point me to it?

Thanks.

Raymond.

Parents
  • 2334
    posted
    You could create an unbound column that stores the row index and set the column to be hidden so it is not visible to the user. then add a Row Filter that only shows where the cell value is less than 5. You will have to handle the sort event so you can reset the value in each row. see below.

    In InitializeLayout event:

    UltraGridColumn colRowIndex = e.Layout.Bands[0].Columns.Add("rowIndex");
    colRowIndex.DataType = typeof(int);
    colRowIndex.Hidden = true;
    applyFilter();


    In InitializeRow event:

    e.Row.Cells["rowIndex"].Value = e.Row.Index;


    In BeforeSortChange event:

    e.Band.ColumnFilters.ClearAllFilters();


    In AfterSortChange event:

    grid.Rows.Refresh(Infragistics.Win.UltraWinGrid.RefreshRow.FireInitializeRow);
    applyFilter();


    In applyFilter:

    grid.DisplayLayout.Bands[0].ColumnFilters["rowIndex"].FilterConditions.Add(Infragistics.Win.UltraWinGrid.FilterComparisionOperator.LessThan, 5);
Reply Children