The iOS Components iOS DataGrid is a very powerful tool. Our support team regularly assists our customers with questions and tips. In this blog post, we are going to cover some questions that our customers have asked, and our responses:
1) Is it possible to decrease or increase the height of rows in the Data Grid Table in a fixed way?
Absolutely. There are many ways to do this. First, and the easiest is to simply set the “rowHeight” property, either in your XML configuration for the grid, or via the API. The value is in pixels. While you are at it, we also have footerRowHeight, filterRowHeight, headerRowHeight, pagerRowHeight (this is the height of the toolbar). Secondly, we have the concept of variable row heights. This is important when you have large blocks of text that don’t fit in one row. The way this works is that you set variableRowHeight=true, and then on the column that holds the variable height text, you set wordWrap=true. This makes the grid measure the amount of space required to render the row completely without cropping and assign the tallest such height of each cell with wordWrap to the entire row.
2) How to set text align?
Similar to above, there is a textAlign property on each column. Just set it to one of “left”, “right” or “center” strings. Similar to textAlign, there is headerAlign, footerAlign. One caveat, is that the current release has textAlign as a NSString. The values if you set in XML is left, right or center, but if you do this programmatically, please use one of the integer values (In quotes as a string) e.g. col.textAlign=@”1”;// this is center
- NSTextAlignmentLeft = 0,
- NSTextAlignmentCenter = 1,
- NSTextAlignmentRight = 2,
- NSTextAlignmentJustified = 3,
- NSTextAlignmentNatural = 4,
3) Is it possible to simply change the color of the text and/or background of a column ?
Absolutely : In your xml, set columnTextColor="0xFF0000" backgroundColor="0x000000". This will color the text red and the background black. You can also do this from code if you set column.columnTextColor = [UIColor redColor]. There are numerous properties that help you set colors for various cells – headerColors, footerColors, pagerColors, columnGroupColors, alternatingItemColors. For headerColors, footerColors, pagerColors, and columnGroupColors, you can specify multiple items in the array and it will generate a gradient. For alternatingItemColors, it is an array of alternating item colors for the rows. Finally, if all these properties are not enough for your needs, you can programmatically set colors. If you see our examples, there is a demo called Programmatic Cell Formatting, which demonstrates this. Moreover, if you look at FLXSStyleManager in the demo code, you will see a vast API that allows you to customize the look and feel of the grid. You can also use the built in themes: [[FLXSStyleManager instance] applyOfficeBlueStyle:flxsDataGrid];