Related to issue 22901: Added a way to define in the own widget
authorDavid Baz Fayos <david.baz@openbravo.com>
Sun, 27 Jan 2013 00:38:37 +0100
changeset 19457 16eca807e2a3
parent 19456 603290cb6a8a
child 19458 8215f88cf681
Related to issue 22901: Added a way to define in the own widget
if it should be displayed or not if the row is in edit mode
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Sat Jan 26 21:51:40 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Sun Jan 27 00:38:37 2013 +0100
@@ -171,14 +171,14 @@
     var field = this.getField(colNum),
         rowNum = this.getRecordIndex(record),
         isEditRecord = rowNum === this.getEditRow(),
-        canvas, clientClass, clientClassPropsStartPosition, clientClassProps;
+        canvas, clientClass, clientClassPropsStartPosition, clientClassProps, clientClassIsShownInEdit;
 
     if (field.isLink && !field.clientClass && record[field.name]) {
       // To keep compatibility with < 3.0MP20 versions that didn't implement 'clientClass' and only have 'isLink' property
       field.clientClass = 'OBGridLinkCellClick';
     }
 
-    if (field.clientClass && !isEditRecord) {
+    if (field.clientClass) {
       clientClass = field.clientClass;
       clientClassPropsStartPosition = clientClass.indexOf('{');
       if (clientClassPropsStartPosition > 0) {
@@ -194,19 +194,23 @@
       }
       clientClass = clientClass.replace(/\s+/g, '');
 
-      canvas = isc.ClassFactory.newInstance(clientClass, {
-        grid: this,
-        align: this.getCellAlign(record, rowNum, colNum),
-        field: field,
-        record: record,
-        rowNum: rowNum,
-        colNum: colNum
-      }, clientClassProps);
-      if (canvas) {
-        if (canvas.setRecord) {
-          canvas.setRecord(record);
+      clientClassIsShownInEdit = new Function('return ' + clientClass + '.getInstanceProperty("isShownInEdit")')();
+
+      if (!isEditRecord || clientClassIsShownInEdit) {
+        canvas = isc.ClassFactory.newInstance(clientClass, {
+          grid: this,
+          align: this.getCellAlign(record, rowNum, colNum),
+          field: field,
+          record: record,
+          rowNum: rowNum,
+          colNum: colNum
+        }, clientClassProps);
+        if (canvas) {
+          if (canvas.setRecord) {
+            canvas.setRecord(record);
+          }
+          return canvas;
         }
-        return canvas;
       }
     }
     return null;
@@ -794,6 +798,7 @@
   height: 1,
   width: '100%',
 
+  isShownInEdit: true,
   initWidget: function () {
     this.btn = isc.OBGridLinkButton.create({});
     this.btn.setTitle(this.title);