Created
May 1, 2012 16:51
-
-
Save jophof/2569576 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<!-- Combo-handled YUI CSS files: --> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/button/assets/skins/sam/button.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/menu/assets/skins/sam/menu.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/fonts/fonts-min.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/base/base-min.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/assets/skins/sam/skin.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/paginator/assets/skins/sam/paginator.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" /> | |
<!--Script and CSS includes for YUI dependencies on this page--> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/button/assets/skins/sam/button.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/calendar/assets/skins/sam/calendar.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/calendar/assets/calendar.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/assets/skins/sam/datatable.css"/> | |
<!-- Dependencies --> | |
<!-- Individual YUI JS files --> | |
<script src="../include/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script> | |
<script src="../include/yui_2.9.0/build/element/element-min.js"></script> | |
<script src="../include/yui_2.9.0/build/paginator/paginator-min.js"></script> | |
<script src="../include/yui_2.9.0/build/datasource/datasource-min.js"></script> | |
<script src="../include/yui_2.9.0/build/datatable/datatable-min.js"></script> | |
<script src="../include/yui_2.9.0/build/container/container_core-min.js"></script> | |
<script src="../include/yui_2.9.0/build/menu/menu-min.js"></script> | |
<script src="../include/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script> | |
<script src="../include/yui_2.9.0/build/animation/animation-min.js" ></script> | |
<script src="../include/yui_2.9.0/build/event-delegate/event-delegate-min.js" ></script> | |
<script src="../include/yui_2.9.0/build/event/event-min.js"></script> | |
<script src="../include/yui_2.9.0/build/dom/dom-min.js"></script> | |
<script src="../include/yui_2.9.0/build/button/button-min.js"></script> | |
<style> | |
.yui-skin-sam .yui-dt-liner { | |
white-space:nowrap; | |
} | |
div.yuimenu .bd { | |
zoom: normal; | |
} | |
</style> | |
</head> | |
<body class="yui-skin-sam" style="background-color:#FEFDDE;"> | |
<div class="yui-skin-sam"> | |
<div id="myContainer"></div> | |
<div id="complex"></div> | |
</div> | |
<div id="scrolling"></div> | |
<div id="count"></div> | |
<script> | |
YAHOO.example.Data = { | |
areacodes: [ | |
{areacode: "201", state: "New Jersey"}, | |
{areacode: "202", state: "Washington, DC"}, | |
{areacode: "203", state: "Connecticut"}, | |
] | |
} | |
YAHOO.util.Event.addListener (window, "load", function() { | |
YAHOO.example.MultipleFeatures = function() { | |
var myColumnDefs = [ | |
{key:"areacode",label:"Area Codes",width:100,resizeable:true,sortable:true}, | |
{key:"state",label:"States",width:250,resizeable:true,sortable:true}, | |
{key:"notes",label:"Notes (editable)",editor:"textbox",resizeable:true,sortable:true} | |
]; | |
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.areacodes); | |
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
myDataSource.responseSchema = { | |
fields: ["areacode","state"] | |
}; | |
var myConfigs = { | |
sortedBy:{key:"areacode",dir:"asc"}, | |
paginator: new YAHOO.widget.Paginator({ | |
rowsPerPage: 25, | |
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE, | |
rowsPerPageOptions: [10,25,50,100], | |
pageLinks: 5 | |
}), | |
draggableColumns:true | |
} | |
var myDataTable = new YAHOO.widget.DataTable("complex", myColumnDefs, myDataSource, myConfigs); | |
myDataTable.subscribe("rowClickEvent",myDataTable.onEventSelectRow); | |
var onContextMenuClick = function(p_sType, p_aArgs, p_myDataTable) { | |
var task = p_aArgs[1]; | |
if(task) { | |
// Extract which TR element triggered the context menu | |
var elRow = this.contextEventTarget; | |
elRow = p_myDataTable.getTrEl(elRow); | |
if(elRow) { | |
switch(task.index) { | |
case 0: // Delete row upon confirmation | |
var oRecord = p_myDataTable.getRecord(elRow); | |
if(confirm("Are you sure you want to delete SKU " + | |
oRecord.getData("SKU") + " (" + | |
oRecord.getData("Description") + ")?")) { | |
p_myDataTable.deleteRow(elRow); | |
} | |
} | |
} | |
} | |
} | |
var myContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", | |
{trigger:myDataTable.getTbodyEl()}); | |
myContextMenu.addItem("Delete Item"); | |
// Render the ContextMenu instance to the parent container of the DataTable | |
myContextMenu.render("myContainer"); | |
myContextMenu.clickEvent.subscribe(onContextMenuClick, myDataTable); | |
return { | |
oDS: myDataSource, | |
oDT: myDataTable | |
}; | |
}(); | |
}); | |
/* | |
YAHOO.example.Data = { | |
bookorders: [ | |
{id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"}, | |
{id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"}, | |
{id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"}, | |
{id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}, | |
{id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"}, | |
{id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"}, | |
{id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"}, | |
{id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}, | |
{id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"}, | |
{id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"}, | |
{id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"}, | |
{id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"} | |
] | |
} | |
YAHOO.util.Event.addListener(window, "load", function() { | |
YAHOO.example.Scrolling = new function() { | |
var myColumnDefs = [ | |
{key:"id", sortable:true, resizeable:true, width:100}, | |
{key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true, width:100}, | |
{key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true, width:50}, | |
{key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true, width:70}, | |
{key:"title", sortable:true, resizeable:true, width:250}, | |
{key:"object"} | |
]; | |
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders); | |
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
myDataSource.responseSchema = { | |
fields: [ | |
{key:"id"}, | |
{key:"date", formatter:"date"}, | |
{key:"quantity"}, | |
{key:"amount"}, | |
{key:"title"}, | |
{key:"object"} | |
] | |
}; | |
// Set height as a string value | |
var myDataTable = new YAHOO.widget.ScrollingDataTable("scrolling", | |
myColumnDefs, myDataSource, {height:"10em"}); | |
myDataTable.addRow ({id:"po-999", date:new Date("March 23, 2011"), quantity:9, amount:9.5, title:"New record", object:"<input type='text' id='xx' value='yy'>"},0); | |
document.getElementById("count").innerHTML += "<span>" + myDataTable._oRecordSet.getLength() + " records retrieved.</span>"; | |
}(); | |
}); | |
*/ | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment