resources/Editors/Editor.Roo.grid.Grid.bjs
authorAlan Knowles <alan@roojs.com>
Fri, 17 Apr 2015 09:12:56 +0000 (17:12 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 17 Apr 2015 09:12:56 +0000 (17:12 +0800)
resources/Editors/Editor.Roo.grid.Grid.js

resources/Editors/Editor.Roo.grid.Grid.bjs
resources/Editors/Editor.Roo.grid.Grid.js

index d9042b1..f137a94 100644 (file)
@@ -21,7 +21,7 @@
     "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
    },
    "| function loadData" : "function(data) { \n\n     alert(\"IPC:TEST:\" + JSON.stringify(data,null,4));\n    var ar = [];\n    for (var k in data) { \n        var r = data[k];\n        var has_s = typeof(r.relates_to_schema) != 'undefined'\n        ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );\n        if (!has_s) {\n            continue;\n        }\n        for (var kk in r.relates_to_schema) {         \n            var rr = r.relates_to_schema[kk];\n            if (rr.Field == r.relates_to_col) {\n                continue;\n            }\n            ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );\n        }\n    }\n    \n    alert(\"IPC:TEST:\" + JSON.stringify(ar));\n    this.grid.dataSource.loadData(ar);\n}",
-   "| function toBJS" : "function() { }",
+   "| function toBJS" : "function() { \n\n// convert the selected cells into a BJS data ready to send back to the UI..\n   \n    this.table = \"XXX\";\n    this.firstTxtCol = \"XXX\";\n   \n   \n    var jreader = {};\n\n    JSON.stringify({\n        '|xns' : 'Roo',\n        xtype : \"GridPanel\",\n        \"title\": this.table,\n        \"fitToframe\": true,\n        \"fitContainer\": true,\n        \"tableName\": this.table,\n        \"background\": true,\n        \"region\" : 'center',\n        \"listeners\": {\n            \"|activate\": \"function() {\\n    _this.panel = this;\\n    if (_this.grid) {\\n        _this.grid.footer.onClick('first');\\n    }\\n}\"\n        },\n        \"items\": [\n            {\n                \"*prop\": \"grid\",\n                \"xtype\": \"Grid\",\n                \"autoExpandColumn\": this.firstTxtCol,\n                \"loadMask\": true,\n                \"listeners\": {\n                    \"|render\": \"function() \\n\" +\n                        \"{\\n\" +\n                        \"    _this.grid = this; \\n\" +\n                        \"    //_this.dialog = Pman.Dialog.FILL_IN\\n\" +\n                        \"    if (_this.panel.active) {\\n\" +\n                        \"       this.footer.onClick('first');\\n\" +\n                        \"    }\\n\" +\n                        \"}\",\n                    \"|rowdblclick\": \"function (_self, rowIndex, e)\\n\" + \n                        \"{\\n\" + \n                        \"    if (!_this.dialog) return;\\n\" + \n                        \"    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\\n\" + \n                        \"        _this.grid.footer.onClick('first');\\n\" + \n                        \"    }); \\n\" + \n                        \"}\\n\"\n                },\n                \"|xns\": \"Roo.grid\",\n\n                \"items\": [\n                    {\n                        \"*prop\": \"dataSource\",\n                        \"xtype\": \"Store\",\n                         remoteSort : true,\n                        '|sortInfo' : \"{ field : '\" + this.firstTxtCol  +  \"', direction: 'ASC' }\", \n                        \"|xns\": \"Roo.data\",\n                        \"items\": [\n                            \n                            {\n                                \"*prop\": \"proxy\",\n                                \"xtype\": \"HttpProxy\",\n                                \"method\": \"GET\",\n                                \"|url\": \"baseURL + '/Roo/\" + this.table + \".php'\",\n                                \"|xns\": \"Roo.data\"\n                            },\n                            jreader\n                        ]\n                    },\n                    {\n                        \"*prop\": \"footer\",\n                        \"xtype\": \"PagingToolbar\",\n                        \"pageSize\": 25,\n                        \"displayInfo\": true,\n                        \"displayMsg\": \"Displaying \" + this.table + \"{0} - {1} of {2}\",\n                        \"emptyMsg\": \"No \" + this.table + \" found\",\n                        \"|xns\": \"Roo\"\n                    },\n                    {\n                        \"*prop\": \"toolbar\",\n                        \"xtype\": \"Toolbar\",\n                        \"|xns\": \"Roo\",\n                        \"items\": [\n                            {\n                                \"text\": \"Add\",\n                                \"xtype\": \"Button\",\n                                \"cls\": \"x-btn-text-icon\",\n                                \"|icon\": \"Roo.rootURL + 'images/default/dd/drop-add.gif'\",\n                                \"listeners\": {\n                                    \"|click\": \"function()\\n\"+\n                                        \"{\\n\"+\n                                        \"    if (!_this.dialog) return;\\n\" +\n                                        \"    _this.dialog.show( { id : 0 } , function() {\\n\"+\n                                        \"        _this.grid.footer.onClick('first');\\n\"+\n                                        \"   }); \\n\"+\n                                        \"}\\n\"\n                                },\n                                \"|xns\": \"Roo.Toolbar\"\n                            },\n                            {\n                                \"text\": \"Edit\",\n                                \"xtype\": \"Button\",\n                                \"cls\": \"x-btn-text-icon\",\n                                \"|icon\": \"Roo.rootURL + 'images/default/tree/leaf.gif'\",\n                                \"listeners\": {\n                                    \"|click\": \"function()\\n\"+\n                                        \"{\\n\"+\n                                        \"    var s = _this.grid.getSelectionModel().getSelections();\\n\"+\n                                        \"    if (!s.length || (s.length > 1))  {\\n\"+\n                                        \"        Roo.MessageBox.alert(\\\"Error\\\", s.length ? \\\"Select only one Row\\\" : \\\"Select a Row\\\");\\n\"+\n                                        \"        return;\\n\"+\n                                        \"    }\\n\"+\n                                        \"    if (!_this.dialog) return;\\n\" +\n                                        \"    _this.dialog.show(s[0].data, function() {\\n\"+\n                                        \"        _this.grid.footer.onClick('first');\\n\"+\n                                        \"    }); \\n\"+\n                                        \"    \\n\"+\n                                        \"}\\n\" \n                                    \n                                },\n                                \"|xns\": \"Roo.Toolbar\"\n                            },\n                            {\n                                \"text\": \"Delete\",\n                                \"cls\": \"x-btn-text-icon\",\n                                \"|icon\": \"rootURL + '/Pman/templates/images/trash.gif'\",\n                                \"xtype\": \"Button\",\n                                \"listeners\": {\n                                    \"|click\": \"function()\\n\"+\n                                        \"{\\n\"+\n                                        \"     Pman.genericDelete(_this, '\" + reader.table + \"'); \\n\"+\n                                        \"}\\n\"+\n                                        \"        \"\n                                },\n                                \"|xns\": \"Roo.Toolbar\"\n                            }\n                        ]\n                    }, // end toolbar\n                ].concat( reader.colmodel)\n            }\n        ]\n        \n        \n    }, null, 4)\n\n}",
    "fitToframe" : true,
    "background" : false,
    "region" : "center",
index e23097c..f45ff60 100644 (file)
@@ -215,7 +215,149 @@ Editor.Roo.grid.Grid = new Roo.XComponent({
    tableName : 'core_enum',
    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
-   toBJS : function() { },
+   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 = {};
+   
+       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"
+                               },
+                               jreader
+                           ]
+                       },
+                       {
+                           "*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"
+                               },
+                               {
+                                   "text": "Edit",
+                                   "xtype": "Button",
+                                   "cls": "x-btn-text-icon",
+                                   "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
+                                   "listeners": {
+                                       "|click": "function()\n"+
+                                           "{\n"+
+                                           "    var s = _this.grid.getSelectionModel().getSelections();\n"+
+                                           "    if (!s.length || (s.length > 1))  {\n"+
+                                           "        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n"+
+                                           "        return;\n"+
+                                           "    }\n"+
+                                           "    if (!_this.dialog) return;\n" +
+                                           "    _this.dialog.show(s[0].data, function() {\n"+
+                                           "        _this.grid.footer.onClick('first');\n"+
+                                           "    }); \n"+
+                                           "    \n"+
+                                           "}\n" 
+                                       
+                                   },
+                                   "|xns": "Roo.Toolbar"
+                               },
+                               {
+                                   "text": "Delete",
+                                   "cls": "x-btn-text-icon",
+                                   "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                   "xtype": "Button",
+                                   "listeners": {
+                                       "|click": "function()\n"+
+                                           "{\n"+
+                                           "     Pman.genericDelete(_this, '" + reader.table + "'); \n"+
+                                           "}\n"+
+                                           "        "
+                                   },
+                                   "|xns": "Roo.Toolbar"
+                               }
+                           ]
+                       }, // end toolbar
+                   ].concat( reader.colmodel)
+               }
+           ]
+           
+           
+       }, null, 4)
+   
+   },
    xns : Roo,
    xtype : 'GridPanel',
    listeners : {