Skip to content

Commit

Permalink
Updates to release v3.3.3 fix #773 fix #909 fix #918 fix #919 fix #922
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Aug 23, 2019
1 parent 48c2027 commit 3ad9805
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 56 deletions.
8 changes: 6 additions & 2 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ Change Log: `yii2-grid`

## Version 3.3.3

**Date:** _under development_
**Date:** 23-Aug-2019

- (enh #922): Correct documentation for `floatHeaderOptions['top']`.
- (enh #918): Allow specific elements to be skipped from export via `export['skipExportElements']`.
- Update GridView Asset Bundle Dependencies.
- (enh #919, #909): Enhance expand row cell click.
- (enh #917): Correct checkbox column highlight behavior to accomodate changes in yiisoft/yii2#17332.
- (enh #916): Set ActionColumn button label aria-hidden as true for screen reader.
- (enh #916): Set ActionColumn button label `aria-hidden` as true for screen reader.
- (enh #773): Enhance grid grouping for more correct summary calculations for nested `GridView`.

## Version 3.3.2

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ echo GridView::widget([
'responsive' => true,
'hover' => true,
'floatHeader' => true,
'floatHeaderOptions' => ['scrollingTop' => $scrollingTop],
'floatHeaderOptions' => ['top' => $scrollingTop],
'showPageSummary' => true,
'panel' => [
'type' => GridView::TYPE_PRIMARY
Expand Down
7 changes: 4 additions & 3 deletions src/ColumnTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ protected function fetchContentOptions($model, $key, $index)
Html::addCssStyle($options, "width:{$this->width};");
}
$options['data-col-seq'] = array_search($this, $this->grid->columns);
Html::addCssClass($options, $this->grid->options['id']);
return $options;
}

Expand Down Expand Up @@ -609,9 +610,9 @@ protected function initGrouping()
if (empty($this->group)) {
return;
}
Html::addCssClass($this->headerOptions, ['kv-grid-group-header', $this->grid->options['id']]);
Html::addCssClass($this->filterOptions, ['kv-grid-group-filter', $this->grid->options['id']]);
$view = $this->grid->getView();
Html::addCssClass($this->headerOptions, 'kv-grid-group-header');
Html::addCssClass($this->filterOptions, 'kv-grid-group-filter');
$this->headerOptions['data-group-key'] = $this->filterOptions['data-group-key'] = $this->columnKey;
GridGroupAsset::register($view);
$id = $this->grid->options['id'];
Expand All @@ -632,7 +633,7 @@ protected function parseGrouping(&$options, $model, $key, $index)
if (empty($this->group)) {
return;
}
Html::addCssClass($options, 'kv-grid-group');
Html::addCssClass($options, ['kv-grid-group', $this->grid->options['id']]);
$options['data-group-key'] = $this->columnKey;
if (!empty($this->groupOddCssClass)) {
$options['data-odd-css'] = $this->parseVal($this->groupOddCssClass, $model, $key, $index);
Expand Down
31 changes: 31 additions & 0 deletions src/GridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace kartik\grid;

use Closure;
use kartik\base\BootstrapInterface;
use kartik\base\BootstrapTrait;
use kartik\base\Config;
Expand Down Expand Up @@ -923,6 +924,8 @@ class GridView extends YiiGridView implements BootstrapInterface
* - `menuOptions`: _array_, HTML attributes for the export dropdown menu. Defaults to `['class' => 'dropdown-menu
* dropdown-menu-right']`. This property is to be setup exactly as the `options` property required by the
* [[\yii\bootstrap\Dropdown]] widget.
* - `skipExportElements`: _array_, the list of jQuery element selectors that will be skipped and removed from
* export. Defaults to `['.sr-only', '.hide']`.
*/
public $export = [];

Expand Down Expand Up @@ -1219,6 +1222,7 @@ public function renderPageSummary()
if (!isset($this->pageSummaryRowOptions['class'])) {
$this->pageSummaryRowOptions['class'] = ($this->isBs4() ? 'table-' : '') . 'warning kv-page-summary';
}
Html::addCssClass($this->pageSummaryRowOptions, $this->options['id']);
$row = $this->getPageSummaryRow();
if ($row === null) {
return '';
Expand Down Expand Up @@ -1284,6 +1288,31 @@ public function renderTableBody()
return $content;
}

/**
* Renders a table row with the given data model and key.
* @param mixed $model the data model to be rendered
* @param mixed $key the key associated with the data model
* @param int $index the zero-based index of the data model among the model array returned by [[dataProvider]].
* @return string the rendering result
*/
public function renderTableRow($model, $key, $index)
{
$cells = [];
/* @var $column Column */
foreach ($this->columns as $column) {
$cells[] = $column->renderDataCell($model, $key, $index);
}
if ($this->rowOptions instanceof Closure) {
$options = call_user_func($this->rowOptions, $model, $key, $index, $this);
} else {
$options = $this->rowOptions;
}
$options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;
Html::addCssClass($options, $this->options['id']);
$this->rowOptions = $options;
return Html::tag('tr', implode('', $cells), $options);
}

/**
* Renders the toggle data button.
*
Expand Down Expand Up @@ -1575,6 +1604,7 @@ protected function initExport()
],
'options' => ['class' => 'btn ' . $this->_defaultBtnCss, 'title' => Yii::t('kvgrid', 'Export')],
'menuOptions' => ['class' => 'dropdown-menu dropdown-menu-right '],
'skipExportElements' => ['.sr-only', '.hide'],
],
$this->export
);
Expand Down Expand Up @@ -2196,6 +2226,7 @@ protected function registerAssets()
'target' => ArrayHelper::getValue($this->export, 'target', self::TARGET_BLANK),
'messages' => $this->export['messages'],
'exportConversions' => $this->exportConversions,
'skipExportElements' => $this->export['skipExportElements'],
'showConfirmAlert' => ArrayHelper::getValue($this->export, 'showConfirmAlert', true),
]
);
Expand Down
3 changes: 2 additions & 1 deletion src/assets/js/kv-grid-expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ var kvExpandRow;
expandRow(false);
}
}
handler($cell, 'click', function () {
handler($cell, 'click', function (event) {
toggleRow($cell);
event.stopPropagation();
});
handler($row, 'click', function (event) {
var target = event.target, clickDisabled = $(target).length &&
Expand Down
3 changes: 1 addition & 2 deletions src/assets/js/kv-grid-expand.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/assets/js/kv-grid-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
self.messages = gridOpts.messages;
self.target = gridOpts.target;
self.exportConversions = gridOpts.exportConversions;
self.skipExportElements = gridOpts.skipExportElements;
self.showConfirmAlert = gridOpts.showConfirmAlert;
self.action = gridOpts.action;
self.bom = gridOpts.bom;
Expand Down Expand Up @@ -210,10 +211,15 @@
},
clean: function (expType) {
var self = this, $table = self.$table.clone(), $tHead, cssStyles = self.$element.data('cssStyles') || {},
$container = self.$table.closest('.kv-grid-container'),
$container = self.$table.closest('.kv-grid-container'), skipElements = self.skipExportElements,
safeRemove = function (selector) {
$table.find(selector + '.' + self.gridId).remove();
};
if (skipElements.length) {
$.each(skipElements, function(key, selector) {
$table.find(selector).remove();
});
}
if (expType === 'html') {
$table.find('.kv-grid-boolean').remove();
}
Expand Down
Loading

0 comments on commit 3ad9805

Please sign in to comment.