Pman.Tab.AdminCompanies.bjs
[Pman.Admin] / Pman.Tab.AdminTypesCompany.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '001-Pman.Tab.AdminTypesCompany',
12         module : Pman.Tab.AdminTypesCompany,
13         region : 'center',
14         parent : Pman.Tab.AdminTypes,
15         name : "Pman.Tab.AdminTypesCompany",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.AdminTypesCompany = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'GridPanel',
35             xns: Roo,
36             listeners : {
37                 activate : function() {
38                     _this.panel = this;
39                     if (_this.grid) {
40                         _this.grid.footer.onClick('first');
41                     }
42                 }
43             },
44             background : true,
45             fitContainer : true,
46             fitToframe : true,
47             region : 'center',
48             tableName : 'core_company_type',
49             title : "Company Types",
50             grid : {
51                 xtype: 'Grid',
52                 xns: Roo.grid,
53                 listeners : {
54                     render : function() 
55                     {
56                         _this.grid = this; 
57                        _this.dialog = Pman.Dialog.AdminGenericName;
58                         if (_this.panel.active) {
59                            this.footer.onClick('first');
60                         }
61                     },
62                     rowdblclick : function (_self, rowIndex, e)
63                     {
64                         if (!_this.dialog) return;
65                         _this.dialog.show({
66                              id : this.getDataSource().getAt(rowIndex).data.id,
67                             _title : "Edit Company Type",
68                             _table : _this.panel.tableName
69                         }, function() {
70                             _this.grid.footer.onClick('first');
71                         }); 
72                     }
73                 },
74                 autoExpandColumn : 'name',
75                 loadMask : true,
76                 dataSource : {
77                     xtype: 'Store',
78                     xns: Roo.data,
79                     remoteSort : true,
80                     sortInfo : { field : 'name', direction: 'ASC' },
81                     proxy : {
82                         xtype: 'HttpProxy',
83                         xns: Roo.data,
84                         method : 'GET',
85                         url : baseURL + '/Roo/core_company_type.php'
86                     },
87                     reader : {
88                         xtype: 'JsonReader',
89                         xns: Roo.data,
90                         totalProperty : 'total',
91                         root : 'data',
92                         id : 'id',
93                         fields : [
94                             {
95                                 'name': 'id',
96                                 'type': 'int'
97                             },
98                             {
99                                 'name': 'name',
100                                 'type': 'string'
101                             }
102                         ]
103                     }
104                 },
105                 footer : {
106                     xtype: 'PagingToolbar',
107                     xns: Roo,
108                     pageSize : 25,
109                     displayInfo : true,
110                     displayMsg : 'Displaying core_image_type{0} - {1} of {2}',
111                     emptyMsg : 'No core_image_type found'
112                 },
113                 toolbar : {
114                     xtype: 'Toolbar',
115                     xns: Roo,
116                     items : [
117                         {
118                             xtype: 'Button',
119                             xns: Roo.Toolbar,
120                             listeners : {
121                                 click : function()
122                                 {
123                                     if (!_this.dialog) return;
124                                     _this.dialog.show( { 
125                                         id : 0,
126                                         _title : "Add Company Type",
127                                         _table : _this.panel.tableName
128                                      } , function() {
129                                         _this.grid.footer.onClick('first');
130                                    }); 
131                                 }
132                             },
133                             cls : 'x-btn-text-icon',
134                             text : "Add",
135                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
136                         },
137                         {
138                             xtype: 'Button',
139                             xns: Roo.Toolbar,
140                             listeners : {
141                                 click : function()
142                                 {
143                                     var s = _this.grid.getSelectionModel().getSelections();
144                                     if (!s.length || (s.length > 1))  {
145                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
146                                         return;
147                                     }
148                                     if (!_this.dialog) return;
149                                     _this.dialog.show({
150                                         id : s[0].data.id,
151                                         _title : "Edit Company Type",
152                                         _table : _this.panel.tableName
153                                         }, function() {
154                                         _this.grid.footer.onClick('first');
155                                     }); 
156                                     
157                                 }
158                             },
159                             cls : 'x-btn-text-icon',
160                             text : "Edit",
161                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
162                         },
163                         {
164                             xtype: 'Button',
165                             xns: Roo.Toolbar,
166                             listeners : {
167                                 click : function()
168                                 {
169                                      Pman.genericDelete(_this, 'core_company_type'); 
170                                 }
171                             },
172                             cls : 'x-btn-text-icon',
173                             text : "Delete",
174                             icon : rootURL + '/Pman/templates/images/trash.gif'
175                         }
176                     ]
177                 },
178                 colModel : [
179                     {
180                         xtype: 'ColumnModel',
181                         xns: Roo.grid,
182                         header : 'Name',
183                         width : 200,
184                         dataIndex : 'name',
185                         renderer : function(v) { return String.format('{0}', v); }
186                     }
187                 ]
188             }
189         });
190         this.layout = this.panel.layout;
191
192     }
193 });