| Page 1 of 1 | [ 4 posts ] |
|
Looking to see if anyone has built a DataTable DataSource for a ModelList?
I have a populated ModelList that I would like to display in a dataTable, looking around I do not see a direct implementation that would support this. I don't have a lot of time to create a new plugin for the dataTable, so I may simply build a tabular View module for the moment, but if a solution exists I would like to take advantage of it. Thanks -Scott |
|
There's nothing out of the box that I know of today, but the plan for DataTable in 3.5.0 is to be based on a model/modellist core with widget view(s).
|
|
I wrote a short plugin to the dataTable that allows the datatable to read my data.
Code: YUI.add("datatableModelPlugin", function(Y) { function DatatableModelPlugin(config){ DatatableModelPlugin.superclass.constructor.apply(this,arguments); } DatatableModelPlugin.NAME='datatableModelPlugin'; DatatableModelPlugin.NS='datatableModelPlugin'; Y.extend(DatatableModelPlugin,Y.Plugin.Base,{ initializer: function() { this.beforeHostMethod('formatDataCell',this.formatDataCell); }, formatDataCell: function (o) { o.value = o.record.get(o.field); return new Y.Do.Halt("",o.formatter.call(this, o)); } }); Y.namespace("MyProject").DatatableModelPlugin = DatatableModelPlugin; }); I am taking advantage of a model list being an ArrayList then simply exchanging the default behavior of the datatable that uses o.value = o.record[o.field] with a .get() call. I have only gone through some basic testing on this but it appears to do the trick. This is probably more generic than just reading a model, I would think it could read any array of Attribute based entities. |
|
Nice. That can be a reference implementation for folks until the DT plumbing is updated. It should be noted that calling get() for each cell will impact performance, but the difference from the current performance might not be noticeable unless the data sets are larger.
Performance is also in the plan for DT 3.5.0. |
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 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
Powered by phpBB® Forum Software © phpBB Group