OS3Grid Advanced Example: Setting and Using Styles

By Fabio Rotondo - fsoft (@) sourceforge ( dot ) net

Main Page
Simple Grid
Sortable Grid
Sortable Grid
Editable Grid
Custom Callbacks
Rows Selection
Setting and Using Styles
Using OS3Grid to edit a dataset
Advanced Cell Value Manipulation
Support OS3Grid
Since version 0.4 of OS3Grid, the user is able to define and use styles, a graphical layout of rows that can be defined by the code. Each row in the table can have its own style and settings are saved even when the user sorts grid rows.
Styles are a better solution than set_row_color(), because the latter requires a row number to be set, while styles are dynamically linked to rows.
By default, OS3Grid provide these styles: These style are predefined, but this does not limit you with these: you can define your own. To define a new style, follow the example below, in which we are setting a new style yellow.
// To set the new style, you have to define "stylename" + 0 and "stylename" + 1 g.cols [ "yellow0" ] = "#f0dc04"; g.cols [ "yellow1" ] = "#fcfc68";
To use a defined (or pre-defined) style inside your grid, you have two choices: