]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
rearranging some classes around for better re-use. added an initial auto-grid, need...
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / widget / AutoGrid.js
1 if(!dojo._hasResource['openils.widget.AutoGrid']) {
2     dojo.provide('openils.widget.AutoGrid');
3     dojo.require('dojox.grid.DataGrid');
4     dojo.require('openils.widget.AutoWidget');
5     dojo.require('openils.Util');
6
7     dojo.declare(
8         'openils.widget.AutoGrid',
9         [dojox.grid.DataGrid, openils.widget.AutoWidget],
10         {
11             startup : function() {
12                 this.inherited(arguments);
13                 this.initAutoEnv();
14                 var existing = (this.structure) ? this.structure[0].cells[0] : [];
15                 var fields = [];
16                 for(var f in this.sortedFieldList) {
17                     var field = this.sortedFieldList[f];
18                     if(!field || field.virtual) continue;
19                     var entry = existing.filter(function(i){return (i.field == field.name)})[0];
20                     if(entry) entry.name = field.label;
21                     else entry = {field:field.name, name:field.label};
22                     fields.push(entry);
23                 }
24                 this.setStructure([{cells: [fields]}]);
25                 this.setStore(this.buildAutoStore());
26             },
27         }
28     );
29     openils.widget.AutoGrid.markupFactory = dojox.grid.DataGrid.markupFactory;
30 }
31