The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
See 6 more by this user. Created: 07/6/11
Project: YUI 3
License: YUI BSD
YUI Version: 3.3.0
Free for use.
Creating a table with no caption still creates the caption node. The main problem is that the caption node is styled with 1em padding, which
causes unwanted whitespace.
In 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);
});
All code on this site is licensed under the BSD License unless stated otherwise.