datatable-sort-source.mustache revision a3b15d60042c81a524cebb94370e5a234a19d04b
<div id="sort" class="yui3-skin-sam dt-example"></div>
<div id="presorted" class="yui3-skin-sam dt-example"></div>
<div id="dblclick" class="yui3-skin-sam dt-example"></div>
<script type="text/javascript">
YUI().use("datatable-sort", function (Y) {
var cols = [
{key:"Company", label:"Click to Sort Column A", sortable:true},
{key:"Phone", label:"Not Sortable Column B"},
{key:"Contact", label:"Click to Sort Column C", sortable:true}
],
dblclickCols = [
{key:"Company", label:"Dblclick to Sort A", sortable:true},
{key:"Phone", label:"Not Sortable Column B"},
{key:"Contact", label:"Dblclick to Sort C", sortable:true}
],
data = [
{Company:"Company Bee", Phone:"415-555-1234", Contact:"Sally Spencer"},
{Company:"Acme Company", Phone:"650-555-4444", Contact:"John Jones"},
{Company:"Industrial Industries", Phone:"408-555-5678", Contact:"Robin Smith"}
],
presortedData = [
{Company:"Acme Company", Phone:"415-555-1234", Contact:"John Jones"},
{Company:"Company Bee", Phone:"650-555-4444", Contact:"Sally Spencer"},
{Company:"Industrial Industries", Phone:"408-555-5678", Contact:"Robin Smith"}
],
dt1 = new Y.DataTable.Base({columnset:cols, recordset:data, summary:"Contacts list", caption:"Table with simple column sorting"}).plug(Y.Plugin.DataTableSort).render("#sort"),
dt2 = new Y.DataTable.Base({columnset:cols, recordset:presortedData, summary:"Contacts list", caption:"This table loads with presorted data"}).plug(Y.Plugin.DataTableSort, {lastSortedBy:{key:"Company",dir:"asc"}}).render("#presorted"),
dt3 = new Y.DataTable.Base({columnset:dblclickCols, recordset:data, summary:"Contacts list", caption:"This table sorts on doubleclick"}).plug(Y.Plugin.DataTableSort, {trigger:{selector:"th",event:"dblclick"}, template:"{value}"}).render("#dblclick");
});
</script>