details: /erp/devel/pi/rev/0e5a25682f31
changeset: 9437:0e5a25682f31
user: Martin Taal <martin.taal <at> openbravo.com>
date: Tue Dec 28 13:58:23 2010 +0100
summary: Added formatting to grid link button functionality
details: /erp/devel/pi/rev/f966e2f3dd29
changeset: 9438:f966e2f3dd29
user: Martin Taal <martin.taal <at> openbravo.com>
date: Tue Dec 28 13:58:45 2010 +0100
summary: Moved properties to generic OBGrid class
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
| 55 ++++++---
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 25 ++--
2 files changed, 48 insertions(+), 32 deletions(-)
diffs (193 lines):
diff -r 73c9a3d5709a -r f966e2f3dd29
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
Tue Dec 28 13:57:35 2010 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
Tue Dec 28 13:58:45 2010 +0100
@@ -16,7 +16,6 @@
* Contributor(s): ______________________________________.
************************************************************************
*/
-
isc.ClassFactory.defineClass('OBGrid', isc.ListGrid);
// = OBGrid =
@@ -31,13 +30,13 @@
showRecordComponents: true,
createRecordComponent: function(record, colNum){
- var field = this.getField(colNum);
+ var field = this.getField(colNum), rowNum = this.getRecordIndex(record);
if (field.isLink && record[field.name]) {
var linkButton = isc.OBGridLinkButton.create({
grid: this,
- title: record[field.name],
+ title: this.formatLinkValue(record, field, colNum, rowNum,
record[field.name]),
record: record,
- rowNum: this.getRecordIndex(record),
+ rowNum: rowNum,
colNum: colNum
});
return linkButton;
@@ -46,17 +45,31 @@
},
updateRecordComponent: function(record, colNum, component, recordChanged){
- var field = this.getField(colNum);
+ var field = this.getField(colNum), rowNum = this.getRecordIndex(record);
if (field.isLink && record[field.name]) {
- component.setTitle(record[field.name]);
+ component.setTitle(this.formatLinkValue(record, field, colNum, rowNum,
record[field.name]));
component.record = record;
- component.rowNum = this.getRecordIndex(record);
+ component.rowNum = rowNum;
component.colNum = colNum;
return component;
}
return null;
},
+ formatLinkValue: function(record, field, colNum, rowNum, value){
+ if (typeof value === 'undefined' || value === null) {
+ return '';
+ }
+ var simpleType = isc.SimpleType.getType(field.type, this.dataSource);
+ // note: originalFormatCellValue is set in the initWidget below
+ if (field && field.originalFormatCellValue) {
+ return field.originalFormatCellValue(value, record, rowNum, colNum,
this);
+ } else if (simpleType.shortDisplayFormatter) {
+ return simpleType.shortDisplayFormatter(value, field, this, record,
rowNum, colNum);
+ }
+ return value;
+ },
+
initWidget: function(){
// prevent the value to be displayed in case of a link
var i, field, formatCellValueFunction = function(value, record, rowNum,
colNum, grid){
@@ -65,6 +78,11 @@
for (i = 0; i < this.fields.length; i++) {
field = this.fields[i];
if (field.isLink) {
+ // store the originalFormatCellValue if not already set
+ if (field.formatCellValue && !field.formatCellValueFunctionReplaced) {
+ field.originalFormatCellValue = field.formatCellValue;
+ }
+ field.formatCellValueFunctionReplaced = true;
field.formatCellValue = formatCellValueFunction;
}
}
@@ -78,17 +96,15 @@
// * {{{exportProperties}}} defines different properties used for
controlling the export, currently only the
// exportProperties.exportFormat is supported (which is defaulted to csv).
// * {{{data}}} the parameters to post to the server, in addition the filter
criteria of the grid are posted.
- exportData: function(exportProperties, data) {
- var d = data || {},
- expProp = exportProperties || {},
- dsURL = this.dataSource.dataURL;
-
+ exportData: function(exportProperties, data){
+ var d = data || {}, expProp = exportProperties || {}, dsURL =
this.dataSource.dataURL;
+
isc.addProperties(d, {
- _dataSource: this.dataSource.ID,
- _operationType: 'fetch',
- _noCount: true, // never do count for export
- exportAs: expProp.exportAs || 'csv',
- exportToFile: true
+ _dataSource: this.dataSource.ID,
+ _operationType: 'fetch',
+ _noCount: true, // never do count for export
+ exportAs: expProp.exportAs || 'csv',
+ exportToFile: true
}, this.getCriteria());
OB.Utilities.postThroughHiddenForm(dsURL, d);
@@ -98,12 +114,12 @@
isc.ClassFactory.defineClass('OBGridSummary', isc.OBGrid);
isc.OBGridSummary.addProperties({
- getCellStyle: function (record, rowNum, colNum) {
+ getCellStyle: function(record, rowNum, colNum){
var field = this.getField(colNum);
if (field.summaryFunction === "sum" && this.summaryRowStyle_sum) {
return this.summaryRowStyle_sum;
} else if (field.summaryFunction === "avg" && this.summaryRowStyle_avg) {
- return this.summaryRowStyle_avg
+ return this.summaryRowStyle_avg;
} else {
return this.summaryRowStyle;
}
@@ -114,7 +130,6 @@
isc.ClassFactory.defineClass('OBGridLinkButton', isc.Button);
isc.OBGridLinkButton.addProperties({
-
action: function(){
if (this.grid && this.grid.cellClick) {
this.grid.cellClick(this.record, this.rowNum, this.colNum);
diff -r 73c9a3d5709a -r f966e2f3dd29
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Tue Dec 28 13:57:35 2010 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Tue Dec 28 13:58:45 2010 +0100
@@ -78,8 +78,12 @@
// ** {{{ dataPageSize }}} **
// The data page size used for loading paged data from the server.
dataPageSize: 100,
-
+
+ autoFitFieldWidths: true,
+ autoFitWidthApproach: 'title',
+ canAutoFitFields: false,
width: '100%',
+
autoFetchTextMatchStyle: 'substring',
showFilterEditor: true,
canEdit: true,
@@ -94,15 +98,11 @@
editEvent: 'none',
showCellContextMenus: true,
canOpenRecordEditor: true,
- canAutoFitFields: false,
showDetailFields: true,
// internal sc grid property, see the ListGrid source code
preserveEditsOnSetData: false,
- autoFitFieldWidths: true,
- autoFitWidthApproach: 'title',
-
waitForSave: true,
stopOnErrors: true,
confirmDiscardEdits: true,
@@ -138,12 +138,6 @@
}
},
- recordComponentPoolingMode: 'recycle',
- showRecordComponentsByCell: true,
- recordComponentPosition: 'within',
- poolComponentsPerColumn: true,
- showRecordComponents: true,
-
currentEditColumnLayout: null,
refreshFields: function(){
@@ -151,7 +145,10 @@
},
createRecordComponent: function(record, colNum){
- var layout = null, rowNum;
+ var layout = this.Super('createRecordComponent',arguments), rowNum;
+ if (layout) {
+ return layout;
+ }
if (this.isEditLinkColumn(colNum)) {
rowNum = this.getRecordIndex(record);
layout = isc.OBGridButtonsComponent.create({
@@ -170,6 +167,10 @@
},
updateRecordComponent: function(record, colNum, component, recordChanged){
+ var superComponent = this.Super('updateRecordComponent', arguments);
+ if (superComponent) {
+ return superComponent;
+ }
if (this.isEditLinkColumn(colNum)) {
// clear the previous record pointer
if (recordChanged && component.record.editColumnLayout === component) {
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits