Pman.Tab.CmsProduct.js
[Pman.Cms] / Pman.Tab.CmsCategoryType.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 : '999-Pman.Tab.CmsCategoryType',
12         module : Pman.Tab.CmsCategoryType,
13         region : 'center',
14         parent : Pman.Tab.Cms,
15         name : "Pman.Tab.CmsCategoryType",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.CmsCategoryType = 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 : 'cms_category_type',
49             title : "Category 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.CmsCategoryType;
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( this.getDataSource().getAt(rowIndex), function() {
66                             _this.grid.footer.onClick('first');
67                         }); 
68                     }
69                 },
70                 autoExpandColumn : 'name',
71                 loadMask : true,
72                 dataSource : {
73                     xtype: 'Store',
74                     xns: Roo.data,
75                     remoteSort : true,
76                     sortInfo : { field : 'name', direction: 'ASC' },
77                     proxy : {
78                         xtype: 'HttpProxy',
79                         xns: Roo.data,
80                         method : 'GET',
81                         url : baseURL + '/Roo/cms_category_type.php'
82                     },
83                     reader : {
84                         xtype: 'JsonReader',
85                         xns: Roo.data,
86                         totalProperty : 'total',
87                         root : 'data',
88                         id : 'id',
89                         fields : [
90                             {
91                                 'name': 'id',
92                                 'type': 'int'
93                             },
94                             {
95                                 'name': 'name',
96                                 'type': 'string'
97                             }
98                         ]
99                     }
100                 },
101                 footer : {
102                     xtype: 'PagingToolbar',
103                     xns: Roo,
104                     pageSize : 25,
105                     displayInfo : true,
106                     displayMsg : 'Displaying cms_category_type{0} - {1} of {2}',
107                     emptyMsg : 'No cms_category_type found'
108                 },
109                 toolbar : {
110                     xtype: 'Toolbar',
111                     xns: Roo,
112                     items : [
113                         {
114                             xtype: 'Fill',
115                             xns: Roo.Toolbar
116                         },
117                         {
118                             xtype: 'Button',
119                             xns: Roo.Toolbar,
120                             text : "Add",
121                             cls : 'x-btn-text-icon',
122                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
123                             listeners : {
124                                 click : function()
125                                 {
126                                     if (!_this.dialog) return;
127                                     _this.dialog.show( { id : 0 } , function() {
128                                         _this.grid.footer.onClick('first');
129                                    }); 
130                                 }
131                             }
132                         },
133                         {
134                             xtype: 'Button',
135                             xns: Roo.Toolbar,
136                             text : "Edit",
137                             cls : 'x-btn-text-icon',
138                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
139                             listeners : {
140                                 click : function()
141                                 {
142                                     var s = _this.grid.getSelectionModel().getSelections();
143                                     if (!s.length || (s.length > 1))  {
144                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
145                                         return;
146                                     }
147                                     if (!_this.dialog) return;
148                                     _this.dialog.show(s[0].data, function() {
149                                         _this.grid.footer.onClick('first');
150                                     }); 
151                                     
152                                 }
153                             }
154                         },
155                         {
156                             xtype: 'Button',
157                             xns: Roo.Toolbar,
158                             text : "Delete",
159                             cls : 'x-btn-text-icon',
160                             icon : rootURL + '/Pman/templates/images/trash.gif',
161                             listeners : {
162                                 click : function()
163                                 {
164                                      Pman.genericDelete(_this, 'cms_category_type'); 
165                                 }
166                             }
167                         }
168                     ]
169                 },
170                 colModel : [
171                     {
172                         xtype: 'ColumnModel',
173                         xns: Roo.grid,
174                         header : 'Name',
175                         width : 200,
176                         dataIndex : 'name',
177                         renderer : function(v) { return String.format('{0}', v); }
178                     }
179                 ]
180             }
181         });
182         this.layout = this.panel.layout;
183
184     }
185 });