- The datatable.js and the datatsource.js were loaded by the dispacher and executed on the fly.
- The datatable.css was also loaded by the dispatcher using the CSS injection feature.
- The destruction's rules will destroy the datatable on content's change..
var myColumnHeaders = [
{key:"id", sortable:true, resizeable:true},
{key:"quantity", type:"number", sortable:true, resizeable:true},
{key:"amount", type:"currency", sortable:true, resizeable:true},
{key:"title", type:"html", sortable:true, resizeable:true}
];
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders);
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema = {
fields: ["id","quantity","amount","title"]
};
var myDataTable = new YAHOO.widget.DataTable("basic", myColumnSet, myDataSource,{caption:"Example: Basic Table"});
// setting the destruction's rules
YAHOO.util.Dispatcher.destroyer.subscribe (function(el, config){
myDataTable.destroy ();
});