OS3Grid Example 5 - Custom Callbacks

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
This next examples shows you how to refine actions when the user clicks on column titles. First of all, we'll show an "Hello World!" message box when the user clicks on "Lastname".
// Column 1 will print "hello world" on click g.set_click_cb ( 1, "alert ( 'hello world!' )" ); // Column "Lastname" does not produce any event on click g.set_click_cb ( 2, -1 );
Since this example is quite simple, we have added also an example on how to call a function each time the grid is rendered. To set a callback each time the grid is rendered on screen, simply refine the "onrender" attribute, this way:
// A callback for each render event g.onrender = rendered;
Callback function should get one argument (the grid instance) like this one:
function rendered ( grid ) { alert ( "Grid: " + grid.id + " rendered" ); }
That's all! The final result is shown below.