Skip to content

Instantly share code, notes, and snippets.

@stlsmiths
Created May 11, 2012 15:14
Show Gist options
  • Save stlsmiths/2660365 to your computer and use it in GitHub Desktop.
Save stlsmiths/2660365 to your computer and use it in GitHub Desktop.
YUI().use( "datatable-scroll", "datatable-message", "datatable-datasource", "datasource-io", "datasource-xmlschema", function (Y) {
//
// Define the DataSource, can't use DataSource.Get with XML (only supports JSON),
// so define an IO DS and plugin the Schema
//
var myDS = new Y.DataSource.IO({ source: '../srvDataGET.php?iact=xml' });
myDS.plug(Y.Plugin.DataSourceXMLSchema, {
schema: {
resultListLocator : 'Results', // was resultsList
resultFields: [ 'ma_id', 'ma_mbid', 'ma_artist', 'ma_album', 'ma_year', 'ma_label' ],
metaFields : {
reply_code : "replyCode",
reply_text : "replyText",
num_recs : "numRecords"
}
}
});
Y.Base.mix( Y.DataTable, [Y.DataTable.Message]);
//
// Create the DataTable, vertical scrolling and sortable columns
//
var myDT = new Y.DataTable({
columns: [
{ key:"ma_artist", label:'Artist Name'},
{ key:"ma_album", label:'Release'},
{ key:"ma_year", label:'Year' },
{ key:"ma_label", label:'Label'}
],
scrollable: 'y',
height: '300px',
// width: '750px', // setting a width eliminates a th/td width mismatch bug
sortable: true
}).render('#dtable');
myDT.showMessage('Loading remote Data ... See TOCACAR!! ');
myDT.plug(Y.Plugin.DataTableDataSource, {
datasource: myDS,
initialRequest: "&iopt=data_music"
});
SyntaxHighlighter.highlight();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment