Now that you have learned all the basics from
Example 1, it is just time to give our grid a bit
of life.
One of the advantages of having a grid on the webpage (from a user point of view) is that you can sort the rows by clicking
on the column names. Let's see how to achieve this with OS3Grid.
In the code presented in
Example 1 add the following line of code before the
g.render()
instruction:
Yeah, you name it! Just a single line of code and you have sortable rows!
But let's get a bit further... What I really like on grids is the ability to have a single row
highlighted when I move the mouse, so I can immediately have a glimpse of all row data at the same time.
This is another one-liner for OS3Grid. Just put this right after (or before :-) the
g.set_sortable()
g.set_highlight ( true );
That's all! The result should be quite similar with the following: