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
How to resize the height of the whole IGGridView after applying a filter
posted

Hello,

I am applying a filter to the data, which results in a new searchModel which my dataset uses.   But regardless of how many rows are within the dataset, the height of the GridView remains the same as the original height (containing blank space below the filtered rows).

Here is my applyFilterWithText method in my datasource:

- (void)gridView:(IGGridView*)gridView applyFilterWithText:(NSString*)filterText

{

    [self.data localSearchWithTerm: filterText ];

    _footerView.text = [self titleForFooter];

    [self.gridView reloadData];

    [self.gridView invalidateIntrinsicContentSize];

}

So you can see that I am calling reloadData and invalidateIntrinsicContentSize, but that does not resize the grid after filtering the results.

I also tried overriding the heightForRowAtPath method like this, but it only gets called for the 2 filtered rows.  The grid height is still the original height:

-(CGFloat)gridView:(IGGridView*)gridView heightForRowAtPath:(IGRowPath*)path

{

    BOOL hasValue = [self.getData containsRowAtIndex:path.rowIndex];

    if (hasValue)

        return 46.0f;

    

    return 0.0f;

}

The only way we found to resize the grid is to re-instantiate the whole grid and re-populate it from scratch.  Could you please let us know how we can resize the grid after applying a filter? 
Thanks,
Alex
Parents
No Data
Reply
  • 40030
    Suggested Answer
    Offline posted

    Hi Alex, 

    When the IGGridView has rows that takes up less space than its bounds, it limits its contentSize to the size of the viewport. This was done on purpose, as usually users do not want the IGGridView to resize, and instead, want the content area to still take at least the full height of the IGGridView.

    I guess you could say the IGGridView wasn't specifically designed to update its height based on its content. And since intrinsicContentSize is just inherited from the UIScrollView there isn't any specific logic to have it magically resize. You'd basically have to set the bounds or frame of the IGGridView to adjust. 

    That being said, i suppose we could add the logic to support this case, however it might have to be an opt-in mechanism, as I could see the argument for both approaches. 

    Out of curiosity, are you never allowing the IGGridView to scroll? Or are you just limiting it to have a max height/width?

    -SteveZ

Children