Eamon Brosnan![]()
Creating a table with no caption still creates the caption node.
The main problem is that the caption node is styled with 1em padding, whichIn this patch we attach or remove the node depending on whether the caption is set.
You can now omit the caption attribute when you instantiate DataTable and the node will not appear in the DOM.
If you set the caption attribute via dt.set('caption') the node will be re-appended to the DOM. If that value becomes null, the node is removed.
YUI().use('gallery-user-patch-2529968', function(Y) {
var mockresponse = {
response: {
results: [
{ "id" : "1", "name" : "Joe" },
{ "id" : "2", "name" : "Andrew" }
]
}
};
var dt = new Y.DataTable.Base({
columnset : [
{ key:"id", sortable: true },
{ key:"name", sortable: true }
],
summary : "User patched DataTable Instance",
recordset : mockresponse.response.results
});
dt.render('#example'); // Now there isn't a 1em padding above the table node
// Although if you want a caption later you can still set it:
dt.set('caption', 'Table showing users');
// And setting it to null will remove it entirely
dt.set('caption', null);
});
© 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