Building a DataTable on information provided by the server
- Since there has been a couple of questions in the past weeks on how to
build a DataTable based on information coming from the server side, I
decided to give it a try instead of just commenting on how it could be done.
You can see the result on:
The client and server side source files are provided in a zip file. The
minimized YUI components are loaded from the YAHOO site.
I used both the server-side pagination and server-side sorting examples from
the YUI examples page as the basis for it but simplified them a lot (just
taking out the YUI Loader makes it so much understandable), so the example
uses the column definitions received from the server as well as relies on it
both for paging and sorting.
The server-side PHP file is the same as used in those examples with the
ability to return the meta-data when requested. As the original file, it
does not use any database connections, it simply has a huge array with the
data in it. Likewise, for the meta-data, I just put another static array.
In practice, both data and meta-data would come from the database.