A DataSource has a rather self-explanatory name ; however, a DataSource Driver in context to the DataGrid can become a very essential key to your software. A DataSource Driver will interact with your data source directly, such as a DB_DataObject or DB_Result object and handle all of the paging and sorting code for you, resulting in very few lines of code that you will need to write.
To use the drivers, you can simply use the bind method, assuming your DataSource is listed below, otherwise you can use the bindDataSource() method. The bind() method will attempt to detect the datasource type and may not be 100% accurate. Because of this chance for error, you may choose to use the bindDataSource method where you can specifically define the datasource driver to use. This method is also the method of choice if you are building your own custom DataSource Driver.
The following listed drivers are currently packaged in with Structures_DataGrid.
The DataObject is the most optimal DataSource for the datagrid because it allows the datagrid to only fetch the necessary records upon rendering. Please note that when binding to a dataobject, do not run the fetch method prior since the datagrid will run the fetch method during the rendering.
When using the DB_Result object, please keep in mind that the sorting will not be automatic and must be done in the SQL directly. Also the paging will not be optimized since your entire result set will be limitied. It is best to implement the LIMIT clause manually unless your database platform does not support this.
XML can simply be presented via the DataGrid. You can bind the Datagrid to a URL directly or via the contents of the XML file.
A CSV file can simply be presented via the DataGrid. You can bind the Datagrid to a URL directly or via the contents of the CSV file.