OS3Grid Example 8 - Column Renderers

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

Main Page
Simple Grid
Sortable Grid
Sortable Grid
Editable Grid
Custom Callbacks
Rows Selection
Column Resize
Column Renderers
Setting and Using Styles
Using OS3Grid to edit a dataset
Advanced Cell Value Manipulation
Support OS3Grid
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: 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.