I implemented gridView:cellForSectionHeader so that I could set .expandable=YES on an IGGridViewSectionHeaderCell. When I click on the section header, I see that gridView:collapseSection and gridView:expandSection are called, and same with gridView:sectionExpanded, but I’m not sure what to do in those to get the sections to expand/collapse when I click on the section headers. Any help is appreciated.
Hi Jeff,
Just as a quick side note: you only need to implement these methods if you're implementing the dataSource protocol yourself. If you happen to use our IGGridViewDataSourceHelper classes, you get this functionality for free.
And just in case you haven't seen the topic, there is a quick overview right here:(however, i'm guessing you've already seen this)
http://help.infragistics.com/iOS/2014.1/?page=IGGridView_Configuring_Expandable_Sections.html
As for an example of the implementation, here is what the DataSource helper actually does:
-(IGGridViewSectionCell *)gridView:(IGGridView *)gridView cellForSectionHeader:(NSInteger)section{ IGGridViewSectionHeaderCell* cell = [IGGridViewSectionHeaderCell gridView:gridView cellForSectionHeader:section]; cell.expandable = YES;// self.allowSectionExpansion;
return cell;
}
-(BOOL)gridView:(IGGridView *)gridView sectionExpanded:(NSInteger)section{ NSNumber* sec = [NSNumber numberWithInteger:section]; return ![_collapsedSections containsObject:sec];} -(void)gridView:(IGGridView *)gridView collapseSection:(NSInteger)section{ NSNumber* sec = [NSNumber numberWithInteger:section]; if(![_collapsedSections containsObject:sec]) { [_collapsedSections addObject:sec]; [gridView updateData]; }} -(void)gridView:(IGGridView *)gridView expandSection:(NSInteger)section{ NSNumber* sec = [NSNumber numberWithInteger:section]; if([_collapsedSections containsObject:sec]) { [_collapsedSections removeObject:sec]; [gridView updateData]; }}
The _collaspedSections field mentioned in the snippet is simply an NSMutableArray.
Essentially, all you're doing is storing off the state of whether a particular section is expanded or collapsed.
Hope this helps!
-SteveZ
Ah, so close. Looks like I was forgetting the call to updateData. I figured out that I must somehow keep track of what section indexes are expanded or not. I'll give it a try.
Yeah, for some cases I do use the data source helper, but in other cases we have a complicated data structure with all sorts of grid requirements that we implement the datasource ourselves.
Thanks.
Hello ,
Thank you for your feedback, as far as I understand your issue was resolved.
Please do not hesitate to contact with us if you need nay further assistance on this matter.