Skip to content

Commit

Permalink
Fix #74, #76: Enhance EditableColumn to allow grid refresh on success
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Sep 4, 2014
1 parent 3b273c6 commit 919e17c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version 1.9.0
2. (enh #67): Fix Chrome bug for displaying loading indicator on tbody.
3. (enh #72): Enhancement for EditableColumn `beforeInput` and `afterInput`.
4. (enh #73): Enhancement for EditableColumn options to be configured as callback.
5. (enh #74,76): Enhance EditableColumn to allow grid refresh on successful update.


Version 1.8.0
Expand Down
18 changes: 18 additions & 0 deletions grid/EditableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class EditableColumn extends DataColumn
*/
public $editableOptions = [];

/**
* @var boolean whether to refresh the grid on successful submission of editable
*/
public $refreshGrid = false;

/**
* @var array the computed editable options
*/
Expand Down Expand Up @@ -77,6 +82,19 @@ public function renderDataCellContent($model, $key, $index)
} else {
$this->_editableOptions['beforeInput'] .= $params;
}
if ($this->refreshGrid) {
$view = $this->grid->getView();
$grid = 'jQuery("#' . $this->grid->options['id'] . '")';
$script =<<< JS
{$grid}.find('.kv-editable-input').each(function() {
var \$input = $(this);
\$input.on('editableSuccess', function(){
{$grid}.yiiGridView("applyFilter");
});
});
JS;
$view->registerJs($script);
}
return Editable::widget($this->_editableOptions);
}
}

0 comments on commit 919e17c

Please sign in to comment.