4 wcmf.grid.Grid =
function() {};
6 wcmf.grid.Grid.prototype = {
35 init:
function(title, type, filter, columnDefs, config, actions, customBtns, customParams) {
37 this.columnDefs = columnDefs;
38 this.actions = actions;
39 this.customParams = customParams;
44 this.pageSize = (config.pagesize != undefined) ? config.pagesize : 10;
50 for (var i=0; i<columnDefs.length; i++)
51 jsonMapping[i] = {name:columnDefs[i].id};
53 jsonMapping.push({name:
"DATATYPE_ATTRIBUTE", mapping:
"values["+dataTypeMapping.DATATYPE_ATTRIBUTE+
"]"});
54 jsonMapping.push({name:
"DATATYPE_IGNORE", mapping:
"values["+dataTypeMapping.DATATYPE_IGNORE+
"]"});
55 jsonMapping.push({name:
"_properties", mapping:
"properties"});
56 jsonMapping.push({name:
"_type", mapping:
"type"});
60 proxy:
new Ext.data.HttpProxy({
61 url:
'<?php echo $APP_URL; ?>'
64 baseParams:{type:type, controller:
'<?php echo $controller; ?>', context:
'<?php echo $context; ?>', usr_action:
'list', response_format:
'JSON', sid:
'<?php echo session_id() ?>', filter:filter, renderValues:
true},
66 reader:
new Ext.data.JsonReader({
68 totalProperty:
'totalCount',
77 storeConfig[
'sortInfo'] = {field:
'config.groupBy', direction:
"ASC"};
78 storeConfig[
'groupField'] = config.groupBy;
79 this.ds =
new Ext.data.GroupingStore(storeConfig);
82 this.ds =
new Ext.data.Store(storeConfig);
87 for (var i in customParams)
88 this.ds.baseParams[i] = customParams[i];
91 for (var i=0; i<columnDefs.length; i++) {
92 columnDefs[i].header =
Message.
get(columnDefs[i].header);
97 for (var i=0; i<columnDefs.length; i++)
98 allColumns.push(columnDefs[i]);
99 for (var i=0; i<this.actions.length; i++)
100 allColumns.push(
this.actions[i]);
105 var cm =
new Ext.grid.ColumnModel(allColumns);
108 var topTb =
new Ext.Toolbar();
109 if (title || config.paging || customBtns) {
113 items.push(customBtns);
119 {text:
'10', tooltip:
Message.
get(
'Display %1% items', [10]), handler:this.setPageSize.createDelegate(
this, [10])},
120 {text:
'25', tooltip:
Message.
get(
'Display %1% items', [25]), handler:this.setPageSize.createDelegate(
this, [25])},
121 {text:
'50', tooltip:
Message.
get(
'Display %1% items', [50]), handler:this.setPageSize.createDelegate(
this, [50])},
122 {text:
'100', tooltip:
Message.
get(
'Display %1% items', [100]), handler:this.setPageSize.createDelegate(
this, [100])}
126 topTb =
new Ext.Toolbar({
132 this.pagingTb =
new Ext.Toolbar();
134 this.pagingTb =
new Ext.PagingToolbar({
136 pageSize:this.pageSize,
138 displayMsg:
Message.
get(
'Displaying {0} - {1} of {2}'),
144 var autoHeight = (config.autoheight) ?
true :
false;
145 var ddRows = (config.ddRows) ?
true :
false;
146 var gridTitle = (config.qtip) ?
'<span qtip="'+config.qtip+
'">'+title+
'</span>' : title;
150 selModel:
new Ext.grid.RowSelectionModel({singleSelect:config.singleSelect}),
151 autoHeight:autoHeight,
152 autoExpandColumn:allColumns[0].
id,
158 enableDragDrop:ddRows,
166 if (config.groupBy) {
167 gridConfig[
'view'] =
new Ext.grid.GroupingView({
169 groupTextTpl:
'{gvalue} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})',
170 hideGroupedColumn:
true,
175 gridConfig[
'viewConfig'] = {
180 this.grid =
new Ext.grid.GridPanel(gridConfig);
183 this.grid.actionPerformed =
function(record, arg, success) {
184 _this.actionPerformed(record, arg, success);
188 this.grid.on(
"celldblclick", this.cellDblClicked,
this);
189 this.grid.on(
"expand", this.onExpand,
this);
193 this.grid.on(
"render",
function(g) {
194 var ddrow =
new Ext.ux.dd.GridReorderDropTarget(g, {
197 beforerowmove:
function(objThis, oldIndex, newIndex, records) {
200 afterrowmove:
function(objThis, oldIndex, newIndex, records) {
201 var dist = oldIndex - newIndex;
202 var actionName = (dist > 0) ?
'sortup' :
'sortdown';
203 Action.perform(actionName, {sortoid:records[0][
'id'], dist:Math.abs(dist), filter:filter, sortcol:config.ddSortCol},
function(record, arg, success){}, _this);
205 beforerowcopy:
function(objThis, oldIndex, newIndex, records) {
208 afterrowcopy:
function(objThis, oldIndex, newIndex, records) {
212 Ext.dd.ScrollManager.register(g.getView().getEditorParent());
214 this.grid.on(
"beforedestroy",
function(g) {
215 Ext.dd.ScrollManager.unregister(g.getView().getEditorParent());
225 this.ds.reload({params:{start:0, limit:this.pageSize},
226 callback:
function() {
227 self.grid.getView().refresh();
236 setPageSize:
function(newPageSize) {
237 this.pageSize = newPageSize;
238 this.pagingTb.pageSize = this.pageSize;
246 getGridImpl:
function() {
253 onExpand:
function(grid) {
260 cellDblClicked:
function(grid, rowIndex, colIndex, e) {
262 var record = this.grid.getStore().getAt(rowIndex);
264 if (this.actions.length > 0) {
265 action = this.actions[0];
266 actionNames = action.getSupportedActions();
267 action.performAction(actionNames[0], record);
274 actionPerformed:
function(record, arg, success) {
281 renderColumnDefault:
function(value, cellMeta, record, rowIndex, colIndex, store) {
283 var value = record.data.DATATYPE_ATTRIBUTE[cellMeta.id];
289 var realSubject = record.data._properties.realSubject;
291 return realSubject.values[dataTypeMapping.DATATYPE_ATTRIBUTE][cellMeta.id];
get($message, $parameters=null, $domain='', $lang='')
Use the Message class to output messages. You need not instantiate a Message object because the metho...