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
630
Displaying aggregate values in section headers
posted

Is there a standard way to display aggregate cell values in section headers, aligned with the cell in question, which supports horizontal scrolling, and supports expandable/collapsible sections?

Right now I can almost make it happen by overriding gridView:viewForSectionHeader, and returning a built-up view of UILabels positioned based on the IGCellPath of the first row of cells. However, it doesn't work when there is horizontal grid scrolling; the section header doesn't scroll along with the grid, which kind of makes sense because then how would the section title show.

I could alternatively just change the section title text to something like: "Section A:  AggValue1:123.45   AggValue2:678.90", but that doesn't align up with the cells, which seems to be the limiting issue in all this.

Any other ideas that could work to simulate a section header that shows aggregate cells values aligned with the cell in question, horizontally scrolls well, and supports expandable/collapsible sections?

Thanks.

Parents
  • 40030
    Suggested Answer
    Offline posted

    There isn't a built in way to do this. But, I wouldn't rule out the possibility through custom code.

    I haven't tested this out, but you could potentially try the following. 

    1. I'd create a custom IGGridViewSectionHeaderCell, instead of using the delegate gridView:viewForSectionHeader: And in that cell, i'd put an additional IGGridView, that contains your display values. If you have the same amount of columns and the same widths, then they'll automatically line up. I'd also disable UserInteraction on the grid, as you don't want it to be interactive. 

    2. On the main IGGridView, i'd use the delegate method, scrollViewDidScroll pathsForVisibleRows. I'd then check the first row, and last row in that returned array to find out the first visible and last visible section. 

    3. Now, in scrollViewDidScroll, you can look up those section cells, they'll have the following path: row:kSectionHeaderIndex column: -1 section:(the actual section index). I'd then update that internal section grid's contentOffset.x to match the contentOffset of the main grid. 

    Let me know if any of this doesn't make any sense :)

    -SteveZ

Reply Children