Initializing a YUI DataSource
In this recipe, we will create a static HTML table of data in the classic way. Once we have created this table, we will go on to use it as the basis for a data source object that we can in turn pass to the YUI DataTable object.
The DataTable control can be created based on any valid YAHOO.util.DataSource
. In keeping with the spirit of the concept of progressive enhancement, in this example we will use an HTML table as the data source. This allows browsers without JavaScript to view a standard HTML table of the data, while browsers with JavaScript enabled can take advantage of these enhancements.
How to do it...
We begin by creating a PHP file (datatable.php) in the cook
directory. This sets up a basic Moodle environment and then displays our data in an HTML table:
<?php require_once(dirname(__FILE__) . '/../config.php'); $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); $PAGE->set_url('/cook/datatable.php'); $PAGE->requires->js('/cook/datatable...