John Lindal![]()
"Treeble" comes from merging "tree" and "table." The original motivation was to enable drilling into the details behind each row in a table, e.g., start with a table which displays sales figures for each continent and then drill into each country, region, and city. Of course, once I started building it, the natural design was to support any hierarchy of data.
Treeble extends Y.DataTable, so all DataTable plugins work with Treebles.
An example of how to wire up TreebleDataSource. my_data is assumed to contain nested arrays, with 'kiddies' being the key for retrieving an item's children.
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2013.04.03-19-53'
}).use('gallery-treeble', function(Y) {
var my_data = [...];
// treeble config to be set on root datasource
var schema =
{
resultFields:
[
"id","quantity","year","title",
{key: 'kiddies', parser: 'treebledatasource'}
]
};
var schema_plugin_config =
{
fn: Y.Plugin.DataSourceArraySchema,
cfg: {schema:schema}
};
var treeble_config =
{
generateRequest: function() { },
schemaPluginConfig: schema_plugin_config,
childNodesKey: 'kiddies',
totalRecordsReturnExpr: '.meta.totalRecords'
};
// root data source
var root = new Y.DataSource.Local({source: data});
root.treeble_config = Y.clone(treeble_config, true);
root.plug(schema_plugin_config);
// TreebleDataSource
var ds = new Y.DataSource.Treeble(
{
root: root,
paginateChildren: false,
uniqueIdKey: 'the-key-which-uniquely-identifies-each-record'
});
// request data
var callback =
{
success: function(e)
{
// do something with e.response.results
},
error: function()
{
// do something with e.error
}
};
ds.sendRequest(
{
request:
{
startIndex: 0,
resultCount: 10
},
callback: callback
});
});| Subject | Author | Date |
|---|---|---|
| Default a node to open? | Brian J. Miller | 02/3/11 |
| Re: Default a node to open? | John Lindal | 04/11/11 |
| Re: Default a node to open? | John Lindal | 04/11/11 |
| Running locally | Scott Vickery | 12/1/11 |
| Re: Running locally | Scott Vickery | 12/1/11 |
| Treeble vs. datatable + add row | Daniel Ji | 03/1/12 |
| Re: Treeble vs. datatable + add row | John Lindal | 03/1/12 |
| Re: Treeble vs. datatable + add row | Daniel Ji | 03/1/12 |
| Re: Treeble vs. datatable + add row | John Lindal | 03/1/12 |
| Re: Treeble vs. datatable + add row | Daniel Ji | 03/1/12 |
© 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