Todd Smith![]()
This is a class extension to DataTable that adds capability to easily add a "checkbox" type record selection that maintains "selected state" after table sorting, pagination or other actions.

Checkbox selection can be turned on or off setting the attribute checkboxSelectMode to true or false.
(See the code sample below or the demos)
A demo working example of this checkbox utility working with Gallery-DataTable-Paginator and for "paginated" local data is at dt_checkbox_select_pag.html
<script src="http://yui.yahooapis.com/3.8.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.09.12-20-02'
}).use('datatable-sort','datatable-scroll','gallery-datatable-checkbox-select', function(Y) {
var dtable = new Y.DataTable({
columns : [ 'port', 'pname', 'ptitle' ],
data: ports,
scrollable: 'y',
height: '250px',
sortable: true,
sortBy: ['pname'],
// Set configuration for two primary keys and enable checkbox selection ...
primaryKeys: [ 'port', 'pname' ],
checkboxSelectMode: true
}).render("#dtable");
// after user has selected some rows, get them and do something with them ...
var selRows = dtable.get('checkboxSelected');
// returns array of objects {tr,record,pkvalues}
});
© 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