Greg Hinch![]()
This plugin allows you to present groups of rows under a single heading, keyed by a given attribute of the records contained within.
By adding the plugin to any DataTable instance and specifying the key to group by, the table will automatically render in groups. The value for "groupBy" can also be a function which will receive a copy of each record in the table and should return a string key to group by. Additionally, a "groupLabelRenderer" can be specified to apply custom formatting to the groups.
YUI().use('gallery-grouped-table', 'datasource-local', function(Y) {
var table = new Y.DataTable({
columnset : [{key : 'firstName'}, {key : 'lastName'}, {key : 'workplace'}],
plugins : [
{fn : Y.Plugin.GroupedDataTable, cfg : {
groupBy : 'workplace'
}}
]
});
// Add data to table ...
table.render(); // Rows will be in groups by "workplace"
});
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info