6ca394d7bb6ed40fb1dbec51877e2e9ec719e0be
[app.Builder.js] / resources / Editors / Editor.Roo.grid.Grid.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Editor.Roo.grid');
6
7 Editor.Roo.grid.Grid = new Roo.XComponent({
8
9  _strings : {
10   '4ce58cbe362a5d7b156992a496d55bf3' :"Database Column",
11   'b78a3223503896721cca1303f776159b' :"Title",
12   '2f616612593df62aeed112de4f03110e' :"Edit a Grid",
13   '0ccc2bf3fb98387c23b6ca5500244d6e' :"Use ",
14   'c671c787b49f50a3ace9fdc5bd597825' :"core_enum",
15   '32954654ac8fe66a1d09be19001de2d4' :"Width",
16   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
17   '6e7376dca68a2386a8737944196ab491' :"Create / Edit Grid"
18  },
19
20   part     :  ["Editors", "Grid" ],
21   order    : '001-Editor.Roo.grid.Grid',
22   region   : 'center',
23   parent   : false,
24   name     : "unnamed module",
25   disabled : false, 
26   permname : '', 
27   _tree : function()
28   {
29    var _this = this;
30    var MODULE = this;
31    return {
32    grid : {
33     ds : {
34      '|xns' : 'Roo.data',
35      data : [
36        [ 1, 'test', 'test', 110 ]
37        
38      
39      ],
40      fields : [ 'active', 'dataIndex', 'type','title', 'width' ],
41      id : 'dataindex',
42      xns : Roo.data,
43      xtype : 'SimpleStore'
44     },
45     toolbar : {
46      '|xns' : 'Roo',
47      xns : Roo,
48      xtype : 'Toolbar',
49      items : [
50       {
51        '|xns' : 'Roo.Toolbar',
52        text : _this._strings['2f616612593df62aeed112de4f03110e'],
53        xns : Roo.Toolbar,
54        xtype : 'TextItem'
55       }
56      ]
57
58     },
59     '|xns' : 'Roo.grid',
60     autoExpandColumn : 'title',
61     clicksToEdit : 1,
62     loadMask : true,
63     xns : Roo.grid,
64     xtype : 'EditorGrid',
65     cm : [
66       {
67        '|xns' : 'Roo.grid',
68        dataIndex : 'active',
69        header : _this._strings['0ccc2bf3fb98387c23b6ca5500244d6e'],
70        renderer : function(v) {  
71            var state = v *1 > 0 ?  '-checked' : '';
72        
73            return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
74                        
75         },
76        width : 75,
77        xns : Roo.grid,
78        xtype : 'ColumnModel'
79       },
80 {
81        '|xns' : 'Roo.grid',
82        dataIndex : 'dataIndex',
83        header : _this._strings['4ce58cbe362a5d7b156992a496d55bf3'],
84        renderer : function(v) { return String.format('{0}', v); },
85        width : 150,
86        xns : Roo.grid,
87        xtype : 'ColumnModel'
88       },
89 {
90        '|xns' : 'Roo.grid',
91        dataIndex : 'type',
92        header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'],
93        renderer : function(v) { return String.format('{0}', v); },
94        width : 100,
95        xns : Roo.grid,
96        xtype : 'ColumnModel'
97       },
98 {
99        editor : {
100         field : {
101          '|xns' : 'Roo.form',
102          xns : Roo.form,
103          xtype : 'TextField'
104         },
105         '|xns' : 'Roo.grid',
106         xns : Roo.grid,
107         xtype : 'GridEditor',
108         items : [
109
110         ]
111
112        },
113        '|xns' : 'Roo.grid',
114        dataIndex : 'title',
115        header : _this._strings['b78a3223503896721cca1303f776159b'],
116        renderer : function(v) { return String.format('{0}', v); },
117        width : 75,
118        xns : Roo.grid,
119        xtype : 'ColumnModel',
120        items : [
121
122        ]
123
124       },
125 {
126        editor : {
127         field : {
128          '|xns' : 'Roo.form',
129          decimalPrecision : 0,
130          xns : Roo.form,
131          xtype : 'NumberField'
132         },
133         '|xns' : 'Roo.grid',
134         xns : Roo.grid,
135         xtype : 'GridEditor',
136         items : [
137
138         ]
139
140        },
141        '|xns' : 'Roo.grid',
142        dataIndex : 'width',
143        header : _this._strings['32954654ac8fe66a1d09be19001de2d4'],
144        renderer : function(v) { return String.format('{0}', v); },
145        width : 75,
146        xns : Roo.grid,
147        xtype : 'ColumnModel',
148        items : [
149
150        ]
151
152       }
153     ],
154     listeners : {
155      cellclick : function (_self, rowIndex, columnIndex, e)
156       {
157       
158               var di = this.colModel.getDataIndex(columnIndex);
159               if (di != 'active') {
160                   return;
161               }
162                
163               var rec = _this.grid.ds.getAt(rowIndex);
164               
165               rec.set('active', rec.data.active * 1 ? 0 : 1);
166               rec.commit();
167                
168               
169       },
170      render : function() 
171       {
172           _this.grid = this; 
173           //_this.dialog = Pman.Dialog.FILL_IN
174       
175       },
176      rowdblclick : function (_self, rowIndex, e)
177       {
178           if (!_this.dialog) return;
179         
180       }
181     },
182     items : [
183
184     ]
185
186    },
187    '|xns' : 'Roo',
188    background : false,
189    fitContainer : true,
190    fitToframe : true,
191    loadData : function(data) { 
192    
193         alert("IPC:TEST:" + JSON.stringify(data,null,4));
194        var ar = [];
195        for (var k in data) { 
196            var r = data[k];
197            var has_s = typeof(r.relates_to_schema) != 'undefined'
198            ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );
199            if (!has_s) {
200                continue;
201            }
202            for (var kk in r.relates_to_schema) {         
203                var rr = r.relates_to_schema[kk];
204                if (rr.Field == r.relates_to_col) {
205                    continue;
206                }
207                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
208            }
209        }
210        
211        alert("IPC:TEST:" + JSON.stringify(ar));
212        this.grid.dataSource.loadData(ar);
213    },
214    region : 'center',
215    tableName : 'core_enum',
216    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
217    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
218    toBJS : function() { 
219    
220    // convert the selected cells into a BJS data ready to send back to the UI..
221       
222        this.table = "XXX";
223        this.firstTxtCol = "XXX";
224       
225        
226        var jreader = {};
227        var     colmodel = [];
228        this.grid.dataSource.each(function(rec) {
229            if (!rec.data.active) {
230                return;
231            }
232            
233            
234            
235            colmodel.push({
236                "xtype": "ColumnModel",
237                "header": rec.data.title,
238                "width":  rec.data.width * 1,
239                "dataIndex": rec.data.dataIndex,
240                "|renderer": !rec.data.type.match(/date/i) ? 
241                        "function(v) { return String.format('{0}', v); }" :
242                        "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
243                "|xns": "Roo.grid",
244                "*prop": "colModel[]"
245            });
246        });
247        
248        
249        
250    
251        alert("IPC:OUT:" + JSON.stringify({
252            '|xns' : 'Roo',
253            xtype : "GridPanel",
254            "title": this.table,
255            "fitToframe": true,
256            "fitContainer": true,
257            "tableName": this.table,
258            "background": true,
259            "region" : 'center',
260            "listeners": {
261                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
262            },
263            "items": [
264                {
265                    "*prop": "grid",
266                    "xtype": "Grid",
267                    "autoExpandColumn": this.firstTxtCol,
268                    "loadMask": true,
269                    "listeners": {
270                        "|render": "function() \n" +
271                            "{\n" +
272                            "    _this.grid = this; \n" +
273                            "    //_this.dialog = Pman.Dialog.FILL_IN\n" +
274                            "    if (_this.panel.active) {\n" +
275                            "       this.footer.onClick('first');\n" +
276                            "    }\n" +
277                            "}",
278                        "|rowdblclick": "function (_self, rowIndex, e)\n" + 
279                            "{\n" + 
280                            "    if (!_this.dialog) return;\n" + 
281                            "    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n" + 
282                            "        _this.grid.footer.onClick('first');\n" + 
283                            "    }); \n" + 
284                            "}\n"
285                    },
286                    "|xns": "Roo.grid",
287    
288                    "items": [
289                        {
290                            "*prop": "dataSource",
291                            "xtype": "Store",
292                             remoteSort : true,
293                            '|sortInfo' : "{ field : '" + this.firstTxtCol  +  "', direction: 'ASC' }", 
294                            "|xns": "Roo.data",
295                            "items": [
296                                
297                                {
298                                    "*prop": "proxy",
299                                    "xtype": "HttpProxy",
300                                    "method": "GET",
301                                    "|url": "baseURL + '/Roo/" + this.table + ".php'",
302                                    "|xns": "Roo.data"
303                                },
304                                {
305                                    '*prop' : 'reader',
306                                    'xtype' : 'JsonReader',
307                                    '|xns' : 'Roo.data',
308                                    'id' : 'id',
309                                    'root' : 'data',
310                                    'totalProperty' : 'total'
311                                }
312                            ]
313                        },
314                        {
315                            "*prop": "footer",
316                            "xtype": "PagingToolbar",
317                            "pageSize": 25,
318                            "displayInfo": true,
319                            "displayMsg": "Displaying " + this.table + "{0} - {1} of {2}",
320                            "emptyMsg": "No " + this.table + " found",
321                            "|xns": "Roo"
322                        },
323                        {
324                            "*prop": "toolbar",
325                            "xtype": "Toolbar",
326                            "|xns": "Roo",
327                            "items": [
328                                {
329                                    "text": "Add",
330                                    "xtype": "Button",
331                                    "cls": "x-btn-text-icon",
332                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
333                                    "listeners": {
334                                        "|click": "function()\n"+
335                                            "{\n"+
336                                            "    if (!_this.dialog) return;\n" +
337                                            "    _this.dialog.show( { id : 0 } , function() {\n"+
338                                            "        _this.grid.footer.onClick('first');\n"+
339                                            "   }); \n"+
340                                            "}\n"
341                                    },
342                                    "|xns": "Roo.Toolbar"
343                                },
344                                 // fill ????
345                                {
346                                    "text": "Delete",
347                                    "cls": "x-btn-text-icon",
348                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
349                                    "xtype": "Button",
350                                    "listeners": {
351                                        "|click": "function()\n"+
352                                            "{\n"+
353                                            "     Pman.genericDelete(_this, '" + this.table + "'); \n"+
354                                            "}\n"+
355                                            "        "
356                                    },
357                                    "|xns": "Roo.Toolbar"
358                                }
359                            ]
360                        }, // end toolbar
361                    ].concat( colmodel)
362                }
363            ]
364            
365            
366        }, null, 4));
367    
368    },
369    xns : Roo,
370    xtype : 'GridPanel',
371    listeners : {
372     activate : function() {
373          _this.panel = this;
374          if (_this.grid) {
375              _this.grid.footer.onClick('first');
376          }
377      }
378    },
379    items : [
380
381    ]
382
383   };  }
384 });