datatable-dsio-source.mustache revision a3b15d60042c81a524cebb94370e5a234a19d04b
6033N/A<style scoped>
6033N/A/* custom styles for this example */
6033N/A.dt-example {margin:1em;}
6033N/A
6033N/A/* css to counter global site css */
6033N/A.dt-example th {text-transform:none;}
6033N/A.dt-example table {width:auto;}
6033N/A.dt-example caption {display:table-caption;}
6033N/A</style>
6033N/A
6033N/A<div id="chinese" class="dt-example"></div>
6033N/A
6033N/A<script type="text/javascript">
6033N/AYUI().use("datasource-io", "datasource-xmlschema","datatable-base","datatable-datasource", function (Y) {
6033N/A var cols = ["Title", "Phone", "Rating"];
6033N/A ds = new Y.DataSource.IO({
6033N/A source:"../assets/datatable/ylocal.xml?"})
6033N/A .plug(Y.Plugin.DataSourceXMLSchema, {
6033N/A schema: {
6033N/A resultListLocator: "Result",
6033N/A resultFields: [
6033N/A {
6033N/A key:"Title",
6033N/A locator:"*[local-name() ='Title']"
6033N/A },
6033N/A {
6033N/A key:"Phone",
6033N/A locator:"*[local-name() ='Phone']"
6033N/A },
6033N/A {
6033N/A key:"Rating",
6033N/A locator:"*[local-name()='Rating']/*[local-name()='AverageRating']",
6033N/A // The data contains "NaN" for unrated restaurants
6033N/A parser: function (val) {
6033N/A return isNaN(val) ? '(none)' : val;
6033N/A }
6033N/A }
6033N/A ]
6033N/A }
6033N/A }),
6033N/A dt = new Y.DataTable.Base({columnset:cols, summary:"Chinese restaurants near 98089", caption:"Table with XML data from same-domain script"})
6033N/A .plug(Y.Plugin.DataTableDataSource, {datasource:ds, initialRequest:"zip=94089&query=chinese"});
6033N/A
6033N/A ds.after("response", function() {
6033N/A dt.render("#chinese")}
6033N/A );
6033N/A});
6033N/A</script>
6033N/A