Sortable, filterable, reorderable table/grid


Need to display some report in tabular format, where the table should support ideally pagination (modifiable page length), and be sortable, with ability to set filters, and if possible (not mandatory) reordering (similar most spread-sheet softwares, like Excel). I would prefer a "client side" approach, s.a. using jQuery, to keep the server side process to a minimum.

Wondering how well such a thing is possible with Yii, has anyone attempted this ? Since I am very new to Yii, would be excellent to have some pointers in this direction.



If you would prefer client-side solution, then why you’re posting on Yii’s forum instead on jQuery’s one? :]

But, seriously! Have you checked CGridView widget? It has everything you’ve mentioned (sorting, filtering and pagination) except reordering, which is not yet implemented as woudl required to much class rewrite to achieve this.

If you’re new to Yii, you should definitely run a demo applications that comes with every Yii release. And also read about Gii generator in the documentation (look for the section “My first Yii application”), which in a few painless steps can generate you a CRUD (Create, Retrieve, Update, Delete) set along with all controller, views etc. ready out-of-the box. After you use Gii to generate CRUD for you, in index action (main page) you’ll have CGridView pretty implemented, ready to be used, without any modification.

For a client-side solution check out DataTables jQuery plugin. Very flexible and extensible implementation of a datagrid, probably solves your problem. Can work with server-side processing too, if needed.

Since you want client-side processing, Yii’s responsibility will be reduced to generating a basic HTML table from your data (EDIT: and including the required javascript files, of course). It’s fairly trivial to implement.