Greg Hinch![]()
The DataFinder class is a utility that works with a Y.DataSource instance to generate query strings, keep track of previously set query parameters, and turn a list of results into a RecordSet. The Record and RecordSet classes are currently almost direct ports of those classes in the YUI 2 DataTable widget.
DataFinder is fairly simple to use, you start by creating a DataSource instance and configuring that with your DataSchema. You then instantiate a DataFinder and attach the DataSource, subscribe to the success and failure events, set any number of query parameters, and execute a fetch.
YUI().use('gallery-datafinder', function(Y) {
var ds = new Y.DataSource.IO({
source : 'test.php?action=testFn'
});
ds.plug({fn : Y.Plugin.DataSourceJSONSchema, cfg : {
schema : {
resultListLocator : "results.list",
resultFields : [
"name",
"email"
]
}
}});
var df = new Y.DataFinder({
dataSource : ds
});
df.after('success', function (args) {
if (args.records) {
var myRecordSet = args.records;
// use RecordSet
}
});
df.after('failure', function (args) {
// Handle the IO failure
});
df.setParam('foo', 'bar');
df.fetch();
});No forum posts for this module.
© 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