upgraded yui to 2.2.2 and yui-ext to 1.0.1a
This commit is contained in:
parent
4d9af2c691
commit
547ced6500
1992 changed files with 645731 additions and 0 deletions
157
www/extras/yui/examples/datatable/formatting.html
Normal file
157
www/extras/yui/examples/datatable/formatting.html
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example: DataTable - Custom Formatting (YUI Library)</title>
|
||||
<link type="text/css" rel="stylesheet" href="../../build/reset/reset.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/fonts/fonts.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/datatable/assets/datatable.css">
|
||||
<link type="text/css" rel="stylesheet" href="./css/examples.css">
|
||||
<link type="text/css" rel="stylesheet" href="../assets/dpSyntaxHighlighter.css">
|
||||
<style type="text/css">
|
||||
/* custom css*/
|
||||
#formatting {margin:1em;}
|
||||
#formatting table {border-collapse:collapse;}
|
||||
#formatting th, #formatting td {border:1px solid #000;padding:.25em;}
|
||||
#formatting th {background-color:#696969;color:#fff;}/*dark gray*/
|
||||
#formatting .yui-dt-odd {background-color:#eee;} /*light gray*/
|
||||
|
||||
#formatting .unread {font-weight:bold;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="hd">
|
||||
<h1><img src="./img/logo.gif" class="logo" alt="Y!"/><a href="./">DataTable Widget</a> :: Custom Formatting</h1>
|
||||
</div>
|
||||
<div id="bd">
|
||||
<div id="formatting"></div>
|
||||
|
||||
<!-- Sample code begins -->
|
||||
<div id="code">
|
||||
<h3>Sample Code</h3>
|
||||
|
||||
<p>Data:</p>
|
||||
|
||||
<textarea name="code" class="JScript" cols="60" rows="1">
|
||||
YAHOO.example.Data.emails = {
|
||||
account:"jenny@yahoo.com",
|
||||
currStorage: 10,
|
||||
maxStorage: 200,
|
||||
messages: [
|
||||
{XID: "9897",Date:new Date(1981, 2, 24),To:"Joe",From:"Jenny",Unread:false,Subject:"Check out my new pictures"},
|
||||
{XID: "7899",Date:new Date(1980, 1, 11),To:"Jane",From:"Jenny",Unread:false,Subject:"Let's have lunch"},
|
||||
{XID: "6789",Date:new Date(1978, 11, 12),To:"Ann",From:"Jenny",Unread:false,Subject:"Here's the info you requested"},
|
||||
{XID: "4996",Date:new Date(1974, 1, 11),To:"Bob",From:"Jenny",Unread:true,Subject:"RE: Let's have lunch"},
|
||||
{XID: "4544",Date:new Date(1974, 1, 10),To:"Charlie",From:"Jenny",Unread:false,Subject:"Birthday party Saturday"}
|
||||
]
|
||||
};
|
||||
</textarea>
|
||||
|
||||
<p>CSS:</p>
|
||||
|
||||
<textarea name="code" class="HTML" cols="60" rows="1">
|
||||
/* custom css*/
|
||||
#formatting {margin:1em;}
|
||||
#formatting table {border-collapse:collapse;}
|
||||
#formatting th, #formatting td {border:1px solid #000;padding:.25em;}
|
||||
#formatting th {background-color:#696969;color:#fff;}/*dark gray*/
|
||||
#formatting .yui-dt-odd {background-color:#eee;} /*light gray*/
|
||||
|
||||
#formatting .unread {font-weight:bold;}
|
||||
</textarea>
|
||||
|
||||
<p>Markup:</p>
|
||||
|
||||
<textarea name="code" class="HTML" cols="60" rows="1">
|
||||
<div id="formatting"></div>
|
||||
</textarea>
|
||||
|
||||
<p>JavaScript:</p>
|
||||
|
||||
<textarea name="code" class="JScript" cols="60" rows="1">
|
||||
// Define a custom formatter for the "New" column
|
||||
var myFormatter = function(elCell, oRecord, oColumn, oData) {
|
||||
if(oRecord["Unread"]) {
|
||||
elCell.innerHTML = "X"; // show an "X" in the column
|
||||
YAHOO.util.Dom.addClass(elCell.parentNode, "unread"); // style the row
|
||||
}
|
||||
};
|
||||
|
||||
// Override the built-in link formatter
|
||||
YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) {
|
||||
var user = oData;
|
||||
elCell.innerHTML = "<a href=\"mailto:" + user + "@foo.com\">" + user + "</a>";
|
||||
};
|
||||
|
||||
var myColumnHeaders = [
|
||||
{text:"New",formatter:myFormatter}, // use a custom formatter
|
||||
{key:"Date",type:"date"}, // use a built-in formatter
|
||||
{key:"To", type:"link"}, // override the built-in formatter
|
||||
{key:"Subject"}
|
||||
];
|
||||
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);
|
||||
|
||||
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.emails);
|
||||
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
|
||||
myDataSource.responseSchema = {
|
||||
resultsList: ["messages"],
|
||||
fields: ["Date","To","From","Subject","XID","Date","Unread"]
|
||||
};
|
||||
|
||||
var myDataTable = new YAHOO.widget.DataTable("formatting",myColumnSet,myDataSource,{caption:"Example: Custom Formatting"});
|
||||
</textarea>
|
||||
</div>
|
||||
<!-- Code sample ends -->
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="../../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../../build/datasource/datasource-beta-debug.js"></script>
|
||||
<script type="text/javascript" src="../../build/datatable/datatable-beta-debug.js"></script>
|
||||
<script type="text/javascript" src="./js/data.js"></script>
|
||||
<script type="text/javascript">
|
||||
var myLogger = new YAHOO.widget.LogReader();
|
||||
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
// Define a custom formatter for the "New" column
|
||||
var myFormatter = function(elCell, oRecord, oColumn, oData) {
|
||||
if(oRecord["Unread"]) {
|
||||
elCell.innerHTML = "X"; // show an "X" in the column
|
||||
YAHOO.util.Dom.addClass(elCell.parentNode, "unread"); // style the row
|
||||
}
|
||||
};
|
||||
|
||||
// Override the built-in formatter
|
||||
YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) {
|
||||
var user = oData;
|
||||
elCell.innerHTML = "<a href=\"mailto:" + user + "@foo.com\">" + user + "</a>";
|
||||
};
|
||||
|
||||
var myColumnHeaders = [
|
||||
{text:"New",formatter:myFormatter}, // use a custom formatter
|
||||
{key:"Date",type:"date"}, // use a built-in formatter
|
||||
{key:"To", type:"link"}, // override the built-in formatter
|
||||
{key:"Subject"}
|
||||
];
|
||||
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);
|
||||
|
||||
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.emails);
|
||||
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
|
||||
myDataSource.responseSchema = {
|
||||
resultsList: ["messages"],
|
||||
fields: ["Date","To","From","Subject","XID","Date","Unread"]
|
||||
};
|
||||
|
||||
var myDataTable = new YAHOO.widget.DataTable("formatting",myColumnSet,myDataSource,{caption:"Example: Custom Formatting"});
|
||||
</script>
|
||||
<script type="text/javascript" src="../assets/dpSyntaxHighlighter.js"></script>
|
||||
<script type="text/javascript">
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue