diff --git a/js/functions.js b/js/functions.js
index 0401f5d195..9fe93d15c1 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2953,8 +2953,8 @@ function PMA_createqTip($elements, content, options) {
function PMA_getCellValue(td) {
if ($(td).is('.null')) {
return '';
- } else if ($(td).is(':not(.truncated, .transformed, .relation, .enum, .set, .null)')) {
- return $(td).find('span').html().replace(/
/g, "\n");
+ } else if ($(td).is(':not(.transformed, .relation, .enum, .set, .null)')) {
+ return unescape($(td).find('span').html()).replace(/
/g, "\n");
} else {
return $(td).text();
}
diff --git a/js/makegrid.js b/js/makegrid.js
index f5bb9012fa..5c0af4897c 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -28,6 +28,7 @@
cellEditHint: '', // hint shown when doing grid edit
gotoLinkText: 'Go to link', // "Go to link" text
wasEditedCellNull: false, // true if last value of the edited cell was NULL
+ maxTruncatedLen: 0, // number of characters that can be displayed in a cell
// functions
dragStartRsz: function(e, obj) { // start column resize
@@ -482,6 +483,7 @@
g.isCellEditActive = false;
g.currentEditCell = cell;
+ $(g.cEdit).find('input[type=text]').focus();
}
} else {
g.hideEditCell();
@@ -538,6 +540,10 @@
}
})
}
+ } else if ($this_field.is('.truncated')) {
+ if (new_html.length > g.maxTruncatedLen) {
+ new_html = new_html.substring(0, g.maxTruncatedLen) + '...';
+ }
}
// replace '\n' with
new_html = new_html.replace(/\n/g, '
');
@@ -784,6 +790,9 @@
}, function(data) {
$editArea.removeClass('edit_area_loading');
if(data.success == true) {
+ // get the truncated data length
+ g.maxTruncatedLen = PMA_getCellValue(g.currentEditCell).length - 3;
+
$(g.cEdit).find('input[type=text]').val(data.value);
$editArea.append('');
$editArea.find('textarea').live('keyup', function(e) {
@@ -1244,7 +1253,6 @@
e.stopPropagation();
} else {
g.showEditCell(this);
- $(g.cEdit).find('input[type=text]').focus();
e.stopPropagation();
}
// prevent default action when clicking on "link" in a table
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 3f402ed0a6..3ed305b2cb 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -1480,10 +1480,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// TEXT fields type so we have to ensure it's really a BLOB
$field_flags = PMA_DBI_field_flags($dt_result, $i);
- // remove 'inline_edit' from $class as we can't edit binary data.
- $class = str_replace('inline_edit', '', $class);
-
if (stristr($field_flags, 'BINARY')) {
+ // remove 'inline_edit' from $class as we can't edit binary data.
+ $class = str_replace('inline_edit', '', $class);
+
if (! isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
} else {
@@ -1512,7 +1512,11 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// characters for tabulations and /
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
- $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
+ if ($is_field_truncated) {
+ $class .= ' truncated';
+ }
+
+ $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
} else {
$vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
}