webgui/www/extras/yui/examples/datatable/dt_rowselect_clean.html
2008-03-25 16:13:25 +00:00

106 lines
No EOL
4.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Row Selection</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="../../build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="../../build/datatable/assets/skins/sam/datatable.css" />
<script type="text/javascript" src="../../build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../../build/element/element-beta-min.js"></script>
<script type="text/javascript" src="../../build/datasource/datasource-beta-min.js"></script>
<script type="text/javascript" src="../../build/datatable/datatable-beta-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
/* custom styles for this example */
.yui-skin-sam .yui-dt-body { cursor:pointer; } /* when rows are selectable */
#single { margin-top:2em; }
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Row Selection</h1>
<div class="exampleIntro">
<p>These examples demonstrate "standard" row selection mode and "single" row
selection mode.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
<div id="standard"></div>
<div id="single"></div>
<script type="text/javascript" src="assets/js/data.js"></script>
<script type="text/javascript">
YAHOO.util.Event.addListener(window, "load", function() {
YAHOO.example.RowSelection = new function() {
var myColumnDefs = [
{key:"Date",formatter:YAHOO.widget.DataTable.formatDate, sortable:true},
{key:"To", sortable:true},
{key:"From", sortable:true},
{key:"Subject", sortable:true}
];
this.myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.emails);
this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
this.myDataSource.responseSchema = {
resultsList: "messages",
fields: ["Date","To","From","Subject","XID","Date","Attachment"]
};
this.standardSelectDataTable = new YAHOO.widget.DataTable("standard",
myColumnDefs, this.myDataSource, {
caption:"Standard Row Selection with Support for Modifier Keys"
});
// Subscribe to events for row selection
this.standardSelectDataTable.subscribe("rowMouseoverEvent", this.standardSelectDataTable.onEventHighlightRow);
this.standardSelectDataTable.subscribe("rowMouseoutEvent", this.standardSelectDataTable.onEventUnhighlightRow);
this.standardSelectDataTable.subscribe("rowClickEvent", this.standardSelectDataTable.onEventSelectRow);
// Programmatically select the first row
this.standardSelectDataTable.selectRow(this.standardSelectDataTable.getTrEl(0));
// Programmatically bring focus to the instance so arrow selection works immediately
this.standardSelectDataTable.focus();
this.singleSelectDataTable = new YAHOO.widget.DataTable("single",
myColumnDefs, this.myDataSource, {
caption:"Single-Row Selection with Modifier Keys Disabled",
selectionMode:"single"
});
// Subscribe to events for row selection
this.singleSelectDataTable.subscribe("rowMouseoverEvent", this.singleSelectDataTable.onEventHighlightRow);
this.singleSelectDataTable.subscribe("rowMouseoutEvent", this.singleSelectDataTable.onEventUnhighlightRow);
this.singleSelectDataTable.subscribe("rowClickEvent", this.singleSelectDataTable.onEventSelectRow);
// Programmatically select the first row
this.singleSelectDataTable.selectRow(this.singleSelectDataTable.getTrEl(0));
};
});
</script>
<!--END SOURCE CODE FOR EXAMPLE =============================== -->
</body>
</html>