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
375
Independent child band sorting
posted

I have a single banded grid bound to an ultradatasource. I load the data on demand via CellDataRequested. This works by setting the number of rows to 1 using SetCount() - this causes a CellDataRequestedEvent, I have a List<T> that contains my data, if this is empty (i.e. initial population) I retrieve 50 rows from the database and stick them in the list, I also get the total number of rows I might want to display and call SetCount() with this. I then populate the datasource form the List<T> as e.Row.index tells me which element from the List<T> I need.

If e.Row.index is higher than the list count it will load another 50 rows (or in fact as many rows as it needs to in order to be able to populate e.Row.Index).

This works pretty well.

If the user clicks a column header to change the sort order I clear all data, make a note of the order I want, cal SetCount(1) and it then goes through the above logic to populate.

Now consider a multi banded grid, I do exactly the same as the above to load/sort the parent band.

When a parent row is expanded I do this:

UltraDataRow expandingRow = (UltraDataRow)e.Row.ListObject;
expandingRow.GetChildRows(myChildBand).SetCount(1);

This forces a CellDataRequested to fire, where I load the data in a similar manner to the parent row, the only exception being that the data is stored in a Dictionary, the key is the unique reference from the parent row, the value is a List<T> of the child rows.

This also works well.

The problem I have is when sorting the child band. If I have two parent rows expanded, when I sort on a child band column both child bands (ie. the cildren for parent row 1 AND parent row 2) get sorted - I don't want this to happen - only the instance of the band that was clicked should be sorted (so just to be clear, I have two parent rows expanded, called 1 and 2. If I click the column header for a column in the child band for parent row 1 the sort indicator should NOT appear against that column header displayed for parent row 2).

Next problem, I need to do a SetCount(1) on the childrows collection for the band that got clicked... this will force the re-population via CellDataRequested.

Sorry for the long winded explanation, but it hopefully expalins what I'm doing.

I have a feeling this will not be possible - in which case is there a mode I can set to force the grid to only allow one row to be expanded at a time ? i.e. when a row is expanded force a collapse of any other expanded rows ? I guess I can do this manually in BeforeRowExpanded if not.

 

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Mark,

    There's no way to tell the grid to only sort one particular island of data. Sorting applies to the entire column which is a member of the band.

    What you might be able to do, though, is set the HeaderClickAction on the columns to one of the "external" sorting options. What this does is allows the grid to provide a UI for sorting by displaying the sort indicator in the column header and toggling it, but the grid won't actually do any sorting. It is left to you, the developer to sort the grid rows. So you could loop through the parent rows and only process sorting for the children of expanded parent rows, without accessing the children of collapsed parent rows.

Reply Children
No Data