From 126b1d543c72d3164005d8765e144fbaa3942967 Mon Sep 17 00:00:00 2001 From: Jonathon Menz Date: Fri, 11 Mar 2016 17:50:52 -0800 Subject: [PATCH] FIX clickable editable rows (fixes #135) --- code/GridFieldEditableColumns.php | 3 +++ javascript/GridFieldExtensions.js | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/GridFieldEditableColumns.php b/code/GridFieldEditableColumns.php index aee407f..3abeac7 100644 --- a/code/GridFieldEditableColumns.php +++ b/code/GridFieldEditableColumns.php @@ -218,6 +218,9 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements )); } + // Add CSS class for interactive fields + if (!($field->isReadOnly() || $field instanceof LiteralField)) $field->addExtraClass('editable-column-field'); + $fields->push($field); } diff --git a/javascript/GridFieldExtensions.js b/javascript/GridFieldExtensions.js index 2a07d26..182fc6e 100644 --- a/javascript/GridFieldExtensions.js +++ b/javascript/GridFieldExtensions.js @@ -165,9 +165,12 @@ * GridFieldEditableColumns */ - $('.ss-gridfield.ss-gridfield-editable .ss-gridfield-item').entwine({ - onclick: function() { - // Stop the default click action when fields are clicked on. + $('.ss-gridfield.ss-gridfield-editable .ss-gridfield-item td').entwine({ + onclick: function(e) { + // Prevent the default row click action when clicking a cell that contains a field + if (this.find('.editable-column-field').length) { + e.stopPropagation(); + } } });