Version 0.5 adds another interesting feature:
Column Renderers.
A column renderer allows you to define a custom visualization function to each column.
In the next example, you'll see how to:
- Bold text inside a cell
- Create a link based upon data contained in a cell
To add a column renderer, you have to define it with the
set_col_renderer()
method before rendering the OS3Grid.
First of all, we'll bold user nick name, creating this renderer:
function bold_render ( txt )
{
return '<strong>' + txt + '<\/strong>';
}
g.set_col_renderer ( 1, bold_render );
Then, we have to create the render that will show up a link in the id column, this way:
// Create link rendered
function link_render ( id )
{
return '<a href="#' + id + ">' + id + '</a>';
}
g.set_col_renderer ( 0, link_render );
That's all! The final result is shown below.