Anyone implement a fixed column in an IGGrid when implementing the data source methods themselves?
The examples I've seen of adding a fixed column on the left side of the grid all appear to use the IGGridViewDataSourceHelper. How would I fix a column to the left side if I am implementing the data source methods myself and not using the helper?
As a quick test, I tried just implementing numberOfFixedLeftColumnsInGridView (returning 1) and widthForFixedLeftColumnAtIndex (returning a width), but they are never called even though I have the delegate set and my other data source methods are called fine, ex: numberOfRowsInSection, cellAt, titleForHeaderInSection, numberOfColumnsInGridView, etc...
Thanks.
Hi Jeff,
You just need to implement:
-(NSInteger)numberOfFixedLeftColumnsInGridView:(IGGridView *)gridView
and
-(IGGridViewCell *)gridView:(IGGridView *)gridView fixedLeftCellAt:(IGCellPath *)path
I've attached a sample that shows this working.
-SteveZ
Thanks. That helped a bunch.
After also implementing widthForFixedLeftColumnAtIndex and fixedLeftHeaderCellAt, and figuring out that numberOfColumnsInGridView should be the number of "non-fixed" columns, it works great!
Glad I could help!
Just out of curiosity, is there a reason you're not using the DataSourceHelpers?
Were you running into issues, or is it that your data structured in a way that it was too much of a headache?
Its worth noting that the DataSourceHelpers are simply objects that implement the IGGridViewDataSource protocol, so you can always extend them and override additional protocol methods.
Correct, you would subclass the DataSourceHelper. Since the DSH implements the DataSourceProtocol, you would just move your current implementation of that method to the subclass.
One other question... I have a custom pull down cell for reload functionality, and the instance method to get that custom cell, pullDownCellForGridView, is on the IGGridViewDataSource protocol. Since I am setting the grid data source to the helper now, this override no longer gets called. Do I have to subclass the helper and add that override there?
Interesting. I will give it a try and see if I can get it working, and then we could reuse some of the custom column types that we will have across the application.
I'll also check out that blog post for an additional resource, and I see that the "Sales" example in the grid demos also uses this approach.
Yes, all of that would be possible using a DSH.
You could override where necessary for example you would need to override the headerCell method for column headers with different background colors.
The rest of what you're describing just requires you to describe column definitions. Basically, you'd turn set the autoGeneratedColumns property on the dataSourceHelper to NO, then add the IGGridViewColumnDefinitions that you want the datasourceHelper to display.
The base IGGridViewColumnDefinition lets you specify the header text and width of the column.
If you want to specify a custom cell, you would create a custom IGGridViewColumnDefinition, and override a single method to use your custom cell.
-(IGGridViewCell*)gridView:(IGGridView*)gridView createCell:(IGCellPath*)path usingDataSource:(IGGridViewDataSourceHelper*)dataSource;
What's nice about this approach is that you can reuse columns and keep your code a bit cleaner.
If you're interested, i could create a sample that shows a couple of different custom columns.
Also, as a resource, you can check out a blog most one of my colleagues created that shows how to create a custom column, in his sample, he places a sparkline in his cell, however, you could really do whatever you'd like.
I would prefer to use the data source helpers, but maybe I incorrectly determined that since our app might have many customized cell views, it might be better to implement the data source methods myself.
Some common properties of our grids:
Would all that be possible using the DSHs? If so, it sounds like you're saying I could start with a DSH, then override the protocol methods where necessary?