Hi, i have a gridview with dynamic number of rows and columns:
the left part is a fixed column (up to the separator blue) and is composed of a custom cell with an imageview and a label
I have not used the IGGridViewDataSourceHelper because I have a complex data structure, but I have implemented all the methods of the protocol datasource in my view controller.
I have not assigned a theme to the grid, but I configured the graphics with the available properties on the gridview, I have no problem if you need to implement a custom theme.
code:
IGGridView* gridView = [[IGGridView alloc] initWithFrame:CGRectZero style:IGGridViewStyleDefault]; [self.view addSubview:gridView]; [gridView setTranslatesAutoresizingMaskIntoConstraints:NO]; gridView.rowHeight = 70; gridView.rowSpacing = 0; gridView.rowSeparatorHeight = .5; gridView.headerTextColor = [UIColor blackColor]; gridView.headerHeight = 60; gridView.headerBackgroundColor = [UIColor defaultHeaderColor]; gridView.headerFont = [UIFont boldSystemFontOfSize:15]; gridView.fixedLeftColumnSeparatorColor = [UIColor appleBlue]; gridView.fixedLeftColumnSeparatorWidth = 1; gridView.rowSeparatorColor = [UIColor lightGrayColor];
//Constraints NSDictionary *views = NSDictionaryOfVariableBindings(gridView); [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[gridView]|" options:0 metrics:nil views:views]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[gridView]|" options:0 metrics:nil views:views]];
questions:
1) I can insert a separator between the header of the columns and the grid? as for the separator of the fixed column
2) how to center the text in the header (the label "Prodotto", etc ...)? I use the default header that generates the grid with - (NSString *) GridView (IGGridView *) GridView titleForHeaderInColumn: (NSInteger) column - (NSString *) GridView (IGGridView *) GridView titleForHeaderInFixedLeftColumn: (NSInteger) column
3) how to insert a separator between columns? Should I make a grid like excel
4) I can not set a minimum width of the columns, if I have many text compresses as shown: when the columns reach the minimum width, the grid should become scrollable
Hi,
2. I just meant my answer for number 1. With your custom header cell.
4. Sorry that was just a typo, i meant IGColumnWidth, not IGGridViewColumnDefinition. And if you need custom values for each column, you can override the following method on the dataSource protocol:
-(IGColumnWidth*)gridView:(IGGridView*)gridView widthForColumnAtIndex:(NSInteger)column;
-SteveZ
Hi Stephen,
1) ok
2) Where can I find your previous answer?
3) ok
4) I implemented my own custom IGGridViewDataSource, without using IGGridViewDataSourceHelper, I haven't IGGridViewColumnDefinition
Hi Mattia,
1. We don't have a built in mechanism for having a separator between the header and all other rows. However, you can create a custom HeaderCell and simply add a view at the bottom of the cell that acts like a separator.
2. If you take the approach i suggested in my previous answer, you can set the header cell's textLabel's textAlignment to NSTextAlignmentCenter.
3. Again, we don't currently have support for column level separators. But you can take a similar approach to what i mentioned above, and instead of a custom IGGridViewHeaderCell, you can create a custom IGGridViewCell that has an extra view on the right side that acts like a separator.
4. I don't really understand the last question. A IGGridViewColumnDefinition does have a minimumWidth property that you could set and the grid will automatically be scrollable when the viewport is smaller than the actual content of the grid.