X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=resources%2FEditors%2FEditor.Roo.grid.Grid.js;h=6ca394d7bb6ed40fb1dbec51877e2e9ec719e0be;hb=42d9a93ede12d1906532ef54d18cb68f8a33e154;hp=584c849d860503044bf892a21b91cbf8544221a3;hpb=83fafd4cec2682ff16b54cc263bee258677c0da2;p=app.Builder.js diff --git a/resources/Editors/Editor.Roo.grid.Grid.js b/resources/Editors/Editor.Roo.grid.Grid.js index 584c849d8..6ca394d7b 100644 --- a/resources/Editors/Editor.Roo.grid.Grid.js +++ b/resources/Editors/Editor.Roo.grid.Grid.js @@ -172,6 +172,11 @@ Editor.Roo.grid.Grid = new Roo.XComponent({ _this.grid = this; //_this.dialog = Pman.Dialog.FILL_IN + }, + rowdblclick : function (_self, rowIndex, e) + { + if (!_this.dialog) return; + } }, items : [ @@ -189,7 +194,18 @@ Editor.Roo.grid.Grid = new Roo.XComponent({ var ar = []; for (var k in data) { var r = data[k]; - ar.push([ false, r.Field, r.Type, r.Field, 100] ); + var has_s = typeof(r.relates_to_schema) != 'undefined' + ar.push([ !has_s , r.Field, r.Type, r.Field, 100] ); + if (!has_s) { + continue; + } + for (var kk in r.relates_to_schema) { + var rr = r.relates_to_schema[kk]; + if (rr.Field == r.relates_to_col) { + continue; + } + ar.push([ false, r.Field + '_'+ rr.Field, rr.Type, rr.Field, 100] ); + } } alert("IPC:TEST:" + JSON.stringify(ar)); @@ -199,6 +215,157 @@ Editor.Roo.grid.Grid = new Roo.XComponent({ tableName : 'core_enum', title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'], title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'], + toBJS : function() { + + // convert the selected cells into a BJS data ready to send back to the UI.. + + this.table = "XXX"; + this.firstTxtCol = "XXX"; + + + var jreader = {}; + var colmodel = []; + this.grid.dataSource.each(function(rec) { + if (!rec.data.active) { + return; + } + + + + colmodel.push({ + "xtype": "ColumnModel", + "header": rec.data.title, + "width": rec.data.width * 1, + "dataIndex": rec.data.dataIndex, + "|renderer": !rec.data.type.match(/date/i) ? + "function(v) { return String.format('{0}', v); }" : + "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date + "|xns": "Roo.grid", + "*prop": "colModel[]" + }); + }); + + + + + alert("IPC:OUT:" + JSON.stringify({ + '|xns' : 'Roo', + xtype : "GridPanel", + "title": this.table, + "fitToframe": true, + "fitContainer": true, + "tableName": this.table, + "background": true, + "region" : 'center', + "listeners": { + "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" + }, + "items": [ + { + "*prop": "grid", + "xtype": "Grid", + "autoExpandColumn": this.firstTxtCol, + "loadMask": true, + "listeners": { + "|render": "function() \n" + + "{\n" + + " _this.grid = this; \n" + + " //_this.dialog = Pman.Dialog.FILL_IN\n" + + " if (_this.panel.active) {\n" + + " this.footer.onClick('first');\n" + + " }\n" + + "}", + "|rowdblclick": "function (_self, rowIndex, e)\n" + + "{\n" + + " if (!_this.dialog) return;\n" + + " _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n" + + " _this.grid.footer.onClick('first');\n" + + " }); \n" + + "}\n" + }, + "|xns": "Roo.grid", + + "items": [ + { + "*prop": "dataSource", + "xtype": "Store", + remoteSort : true, + '|sortInfo' : "{ field : '" + this.firstTxtCol + "', direction: 'ASC' }", + "|xns": "Roo.data", + "items": [ + + { + "*prop": "proxy", + "xtype": "HttpProxy", + "method": "GET", + "|url": "baseURL + '/Roo/" + this.table + ".php'", + "|xns": "Roo.data" + }, + { + '*prop' : 'reader', + 'xtype' : 'JsonReader', + '|xns' : 'Roo.data', + 'id' : 'id', + 'root' : 'data', + 'totalProperty' : 'total' + } + ] + }, + { + "*prop": "footer", + "xtype": "PagingToolbar", + "pageSize": 25, + "displayInfo": true, + "displayMsg": "Displaying " + this.table + "{0} - {1} of {2}", + "emptyMsg": "No " + this.table + " found", + "|xns": "Roo" + }, + { + "*prop": "toolbar", + "xtype": "Toolbar", + "|xns": "Roo", + "items": [ + { + "text": "Add", + "xtype": "Button", + "cls": "x-btn-text-icon", + "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", + "listeners": { + "|click": "function()\n"+ + "{\n"+ + " if (!_this.dialog) return;\n" + + " _this.dialog.show( { id : 0 } , function() {\n"+ + " _this.grid.footer.onClick('first');\n"+ + " }); \n"+ + "}\n" + }, + "|xns": "Roo.Toolbar" + }, + // fill ???? + { + "text": "Delete", + "cls": "x-btn-text-icon", + "|icon": "rootURL + '/Pman/templates/images/trash.gif'", + "xtype": "Button", + "listeners": { + "|click": "function()\n"+ + "{\n"+ + " Pman.genericDelete(_this, '" + this.table + "'); \n"+ + "}\n"+ + " " + }, + "|xns": "Roo.Toolbar" + } + ] + }, // end toolbar + ].concat( colmodel) + } + ] + + + }, null, 4)); + + }, xns : Roo, xtype : 'GridPanel', listeners : {