From d44d4a2ea8bc7c0df916325374813d13bd7d806b Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Tue, 8 Mar 2016 13:02:42 +0000
Subject: [PATCH] SSDM-3292 : Tables now show the text wrapped and cut it when
 size is bigger than 300 chars.

SVN: 35837
---
 .../js/views/DataGrid/ExperimentDataGridUtil.js | 17 ++++++++++++++++-
 .../js/views/DataGrid/SampleDataGridUtil.js     | 17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
index ae53e20ad46..8d0608b2116 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
@@ -79,11 +79,26 @@ var ExperimentDataGridUtil = new function() {
 				var newVocabularyColumnFunc = getVocabularyColumn(propertyType);
 				propertyColumnsToSort.push(newVocabularyColumnFunc());
 			} else {
+				var maxLineLength = 300;
+				var getRenderFunction = function(propertyType) {
+					return function(data) {
+						var propValue = data[propertyType.code];
+						if(propValue) {
+							propValue = propValue.substring(0, maxLineLength);
+							if(data[propertyType.code].length > maxLineLength) {
+								propValue += "...";
+							}
+						}
+						return propValue;
+					}
+				}
+				
 				propertyColumnsToSort.push({
 					label : propertyCodesDisplayNames[idx],
 					property : propertyCodes[idx],
 					isExportable: true,
-					sortable : true
+					sortable : true,
+					render : getRenderFunction(propertyType)
 				});
 			}
 		}
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
index 18866b04aae..8bfc427a216 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
@@ -136,11 +136,26 @@ var SampleDataGridUtil = new function() {
 				var newVocabularyColumnFunc = getVocabularyColumn(propertyType);
 				propertyColumnsToSort.push(newVocabularyColumnFunc());
 			} else {
+				var maxLineLength = 300;
+				var getRenderFunction = function(propertyType) {
+					return function(data) {
+						var propValue = data[propertyType.code];
+						if(propValue) {
+							propValue = propValue.substring(0, maxLineLength);
+							if(data[propertyType.code].length > maxLineLength) {
+								propValue += "...";
+							}
+						}
+						return propValue;
+					}
+				}
+					
 				propertyColumnsToSort.push({
 					label : propertyCodesDisplayNames[idx],
 					property : propertyCodes[idx],
 					isExportable: true,
-					sortable : true
+					sortable : true,
+					render : getRenderFunction(propertyType)
 				});
 			}
 		}
-- 
GitLab