Created
February 15, 2011 11:17
-
-
Save schamane/827416 to your computer and use it in GitHub Desktop.
YUI2 in YUI3 example : http://ericmiraglia.com/yui/demos/2in3dt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI().use('event', 'event-custom', 'yui2-dragdrop', 'yui2-datatable', function (Y) { | |
var YAHOO = Y.YUI2, | |
eventName = '"page:dataTableCreated'; | |
Y.on(eventName, function(oDS, oDT){ | |
Y.log(oDS); | |
Y.log(oDT); | |
}); | |
Y.on("available", function() { | |
//This is the data from which the DataTable will be built: | |
var bookorders = [ | |
{id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing", | |
description: "Lorem ipsum dolor sit amet consectetuer Quisque ipsum suscipit Aenean ligula. Accumsan molestie nibh dui orci vitae auctor nec pulvinar ligula elit."}, | |
{id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life", | |
description: "Vestibulum scelerisque wisi adipiscing turpis odio Phasellus euismod id orci tristique. Hendrerit sem dictum volutpat cursus pretium dui vitae tincidunt Vivamus Aenean."}, | |
{id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud", | |
description: "Malesuada pellentesque nibh magna nisl tincidunt wisi dui Nam nunc convallis. Adipiscing leo augue Nulla tellus nec eros metus cursus pretium Sed."}, | |
{id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice", | |
description: "Libero justo pede nibh tincidunt ut tempus metus et Vestibulum vel. Sem justo morbi lacinia dui turpis In Lorem dictumst volutpat cursus."} | |
]; | |
var myColumnDefs = [ | |
{key:"id", sortable:true, resizeable:true}, | |
{key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true}, | |
{key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true}, | |
{key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true}, | |
{key:"title", sortable:true, resizeable:true} | |
]; | |
var myDataSource = new YAHOO.util.DataSource(bookorders); | |
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
myDataSource.responseSchema = { | |
fields: ["id","date","quantity","amount","title"] | |
}; | |
var myDataTable = new YAHOO.widget.DataTable("basic", | |
myColumnDefs, myDataSource); | |
myDataTable.subscribe("initEvent", function(){ | |
Y.log('******** hello from initEvent'); | |
}); | |
myDataTable.subscribe("rowClickEvent", function(){ | |
Y.log('******** hello from rowClickEvent'); | |
}); | |
Y.fire(eventName, myDataSource, myDataTable ); | |
}, "#basic"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment