作者:lianghongl
项目:yii2-zh-c
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
$name = rtrim($this->name, '[]') . '_all';
$id = $this->grid->options['id'];
$options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]);
$this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
if ($this->header !== null || !$this->multiple) {
return parent::renderHeaderCellContent();
} else {
return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
}
}
作者:arogache
项目:yii2-sortabl
/**
* @inheritdoc
*/
public function init()
{
parent::init();
/* @var $dataProvider ActiveDataProvider */
$dataProvider = $this->grid->dataProvider;
if (!$dataProvider instanceof ActiveDataProvider) {
throw new InvalidConfigException('SortableColumn works only with ActiveDataProvider.');
}
if (!$this->gridContainerId) {
throw new InvalidConfigException('$gridContainerId property must be set.');
}
Yii::setAlias('@sortable', dirname(__DIR__));
Yii::$app->i18n->translations['sortable'] = ['class' => PhpMessageSource::className(), 'basePath' => '@sortable/messages'];
/* @var $query \yii\db\ActiveQuery */
$query = $dataProvider->query;
$this->_model = new $query->modelClass();
$this->contentOptions = function ($model) {
/* @var $model ActiveRecord|BaseNumericalSortableBehavior */
return ['class' => 'sortable-cell', 'data-position' => $model->getSortablePosition()];
};
if (!$this->header) {
$this->header = Yii::t('sortable', 'Sort');
}
$this->visible = $this->isVisible();
if (!$this->template) {
$this->template = '<div class="sortable-section">{currentPosition}</div>
<div class="sortable-section">{moveWithDragAndDrop}</div>
<div class="sortable-section">{moveForward} {moveBack}</div>
<div class="sortable-section">{moveAsFirst} {moveAsLast}</div>';
}
$this->initDefaultButtons();
if (!Yii::$app->request->isAjax) {
$this->registerJs();
}
}
作者:omniligh
项目:yz2-admi
protected function renderFilterCellContent()
{
$filter = $this->guessFilter();
if ($filter instanceof BaseFilter) {
return $filter->render();
}
return Column::renderFilterCellContent();
}
作者:fangfac
项目:yii2-concor
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
if ($this->gridType == 'datatable-select') {
if ($this->header !== null || !$this->multiple) {
return Column::renderHeaderCellContent();
} else {
$name = rtrim($this->name, '[]') . '_all';
return Html::checkBox($name, false, ['class' => 'group-checkable']);
}
} else {
return parent::renderHeaderCellContent();
}
}
作者:Griff1
项目:it_bas
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a('Создать номер', ['create'], ['class' => 'btn btn-success']);
?>
<?php
echo Html::a('Загрузить из файла', ['uploadform'], ['class' => 'btn btn-success']);
?>
</p>
<?php
$cols = [['class' => 'yii\\grid\\SerialColumn'], 'id', 'voip_number', ['attribute' => 'secret', 'value' => function ($model) {
return Html::a($model->secret ? '* * *' : '', '', ['title' => $model->secret]);
}, 'format' => 'raw'], 'description', 'context', ['class' => Column::className(), 'content' => function ($model) use($id_wp) {
return Html::a('Выбрать', ['voipnumbers/choicewp', 'id' => $model->id, 'id_wp' => $id_wp]);
}], ['class' => 'yii\\grid\\ActionColumn']];
if (!isset($id_wp)) {
unset($cols[6]);
}
?>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $cols]);
?>
</div>
作者:Griff1
项目:it_bas
<?php
/**
* User: ivan
* Date: 09.02.2016
* Time: 12:31
*
* @var $this yii\web\View
* @var $dp yii\data\ActiveDataProvider
*/
use yii\grid\GridView;
use yii\helpers\Html;
use yii\grid\Column;
use backend\models\Devices;
$this->title = '' . $title;
$this->params['breadcrumbs'][] = ['label' => 'Отчет', 'url' => ['reports/aindex']];
$this->params['breadcrumbs'][] = $this->title;
echo 'Отчет по устройству';
echo '<h1>' . $title . '</h1>';
echo GridView::widget(['dataProvider' => $dp, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'branch_id', 'label' => 'Подразделение'], ['attribute' => 'workplaces_title', 'label' => 'Рабочее место', 'value' => function ($dp) {
return Html::a($dp['workplaces_title'], ['workplaces/view', 'id' => $dp['workplace_id']]);
}, 'format' => 'raw'], ['class' => Column::className(), 'header' => 'Кол-во', 'content' => function ($dp) use($type_id) {
return Devices::getCountOnWp($type_id, $dp['workplace_id']);
}], ['attribute' => 'snp', 'label' => 'Ответственное лицо'], ['attribute' => 'job_title', 'label' => 'Должность'], ['attribute' => 'date', 'label' => 'Дата']]]);
作者:sx-de
项目:cour
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
$name = $this->name;
if (substr_compare($name, '[]', -2, 2) === 0) {
$name = substr($name, 0, -2);
}
if (substr_compare($name, ']', -1, 1) === 0) {
$name = substr($name, 0, -1) . '_all]';
} else {
$name .= '_all';
}
$id = $this->grid->options['id'];
$options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
if ($this->header !== null || !$this->multiple) {
return parent::renderHeaderCellContent();
} else {
return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
}
}
作者:lurongz
项目:uii2016032
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
$name = rtrim($this->name, '[]') . '_all';
$id = $this->grid->options['id'];
$options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
if ($this->header !== null || !$this->multiple) {
return parent::renderHeaderCellContent();
} else {
// return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
return "<label class=\"control-label\">" . Html::checkBox($name, false, ['class' => 'select-on-check-all']) . "<span class=\"text\"></span></label>";
}
}
作者:derkamera
项目:adminU
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
$name = rtrim($this->name, '[]') . '_all';
$id = $this->grid->options['id'];
$options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]);
$this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
if ($this->header !== null || !$this->multiple) {
return parent::renderHeaderCellContent();
} else {
$content = Html::tag('button', Html::checkBox($name, false, ['class' => 'select-on-check-all', 'data-target' => $this->name, 'data-checkall' => 1, 'data-parent-id' => $id]) . ' <span class="caret"></span>', ['type' => 'button', 'class' => 'btn btn-default dropdown-toggle', 'data-toggle' => 'dropdown']);
$buttons = preg_replace_callback('/\\{([\\w\\-\\/]+)\\}/', function ($matches) use($model, $key, $index) {
$name = $matches[1];
$module = \Yii::$app->user->can(\Yii::$app->controller->module->id . '/' . \Yii::$app->controller->id . '/' . $name);
if ($module) {
if (isset($this->buttons[$name])) {
$url = $this->createUrl($name, $model, $key, $index);
if (call_user_func($this->checkaccess, $url)) {
return call_user_func($this->buttons[$name], $url, $model);
} else {
return '';
}
} else {
return '';
}
}
}, $this->template);
if ($buttons == '') {
return $buttons;
}
$content .= Html::tag('ul', $buttons, ['class' => 'dropdown-menu pull-right', 'role' => 'menu']);
return Html::tag('div', $content, ['class' => 'dropdown']);
}
}
作者:Griff1
项目:it_bas
<?php
echo Html::submitButton('Создать автоматом', ['class' => 'btn btn-success']);
?>
</form>
</div>
<?php
}
?>
<?php
echo GridView::widget(['dataProvider' => $deviceProvider, 'filterModel' => $searchDeviceModel, 'layout' => "{items}", 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'type_id', 'value' => function ($moddev) use($model) {
$str = '-';
if (isset($moddev->type_id)) {
$str = $moddev->deviceType->title;
$str .= empty($moddev->deviceType->synonyms) ? '' : ' (' . $moddev->deviceType->synonyms . ')';
}
return Html::a($str, ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id]);
}, 'format' => 'raw'], 'brand', 'model', 'sn', 'id', ['attribute' => 'device_note', 'value' => function ($moddev) use($model) {
/* @var $moddev \backend\models\Devices */
return Html::a($moddev->device_note, ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id]);
}, 'format' => 'raw'], ['class' => Column::className(), 'content' => function ($moddev) use($model) {
return Html::a(Html::img('/admin/img/view.png', ['style' => 'height:24px']), ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id], ['title' => 'Подробно...']);
//['data-method' => 'post']);
}, 'options' => ['style' => 'width:10px']], ['class' => Column::className(), 'content' => function ($moddev) use($model) {
return Html::a('', ['devices/delfromwp', 'id' => $moddev->id, 'id_wp' => $model->id], ['class' => 'cross', 'title' => 'Удалить устройство с рабочего места...']);
//['data-method' => 'post']);
}, 'options' => ['style' => 'width:10px']]]]);
?>
</div>
</div>
作者:kilyano
项目:yii
/**
* @inheritdoc
* @throws \yii\base\InvalidConfigException if [[name]] is not set.
*/
public function init()
{
parent::init();
if (empty($this->name)) {
throw new InvalidConfigException('The "name" property must be set.');
}
}
作者:alisherdavrono
项目:yii2-grid-sort-column-en
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$script = '
$(document).ready(function(){
function hideFirstLast() {
$(\'.sort-up, .sort-down\').show();
$(\'.sort-up\').first().hide();
$(\'.sort-down\').last().hide();
}
function refresh() {
$(\'#' . $this->grid->id . '\').yiiGridView("applyFilter");
hideFirstLast();
}
$(\'.sort-up\').on(\'click\', function(){
var id = $(this).parent().parent().attr(\'data-key\');
$.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=up").always(refresh);
return false;
});
$(\'.sort-down\').on(\'click\' ,function(){
var id = $(this).parent().parent().attr(\'data-key\');
$.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=down").always(refresh);
return false;
});
hideFirstLast();
});';
$this->grid->getView()->registerJs($script);
}
作者:zulkif
项目:yii2-dropdown-action-column-
/**
* Initializes the object.
* This method is invoked at the end of the constructor after the object is initialized with the
* given configuration.
*/
public function init()
{
if ($this->defaultItems) {
$this->defaultItems = [['label' => Yii::t('yii', 'Update'), 'url' => ['update', 'id' => '{id}']], ['label' => Yii::t('yii', 'View'), 'url' => ['view', 'id' => '{id}']], ['label' => Yii::t('yii', 'Delete'), 'url' => ['delete', 'id' => '{id}']]];
}
parent::init();
}
作者:tqsq200
项目:dotplant
public function init()
{
parent::init();
$this->defaultButtons = [['url' => 'edit', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => Yii::t('app', 'Delete'), 'options' => ['data-action' => 'delete']]];
if (null === $this->buttons) {
$this->buttons = $this->defaultButtons;
} elseif ($this->buttons instanceof Closure) {
$this->callbackButtons = $this->buttons;
}
}
作者:wrt54g
项目:yii2-tabula
/**
* @inheritdoc
*/
protected function renderHeaderCellContent()
{
if ($this->label !== null) {
return $this->label;
}
if ($this->attribute !== null) {
$model = $this->grid->filterModel;
return $model->getAttributeLabel($this->attribute);
}
return parent::renderHeaderCell();
}
作者:nanodesu8
项目:yii2-activerecord-sor
/**
* @inheritDoc
*/
public function init()
{
parent::init();
/**
* @var ActiveDataProvider $provider
* @var ActiveQuery $query
*/
$provider = $this->grid->dataProvider;
Yii2::assertType($provider, ActiveDataProvider::class);
$query = $provider->query;
Yii2::assertType($query, ActiveQuery::class);
$this->provider = $provider;
$this->query = $query;
}
作者:greshni
项目:yii2-grid-sort-colum
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$view = $this->grid->getView();
$script = '
$(document).ready(function(){
function hideFirstLast() {
$(\'.sort-up, .sort-down\').show();
$(\'.sort-up\').first().hide();
$(\'.sort-down\').last().hide();
}
$(\'.sort-up\').on(\'click\', function(){
var element = $(this).parent().parent();
var id1 = element.attr(\'data-key\');
var id2 = element.prev().attr(\'data-key\');
element.prev().before(element);
hideFirstLast();
$.ajax({
url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
});
return false;
});
$(\'.sort-down\').on(\'click\' ,function(){
var element = $(this).parent().parent();
var id1 = element.attr(\'data-key\');
var id2 = element.next().attr(\'data-key\');
element.next().after(element);
hideFirstLast();
$.ajax({
url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
});
return false;
});
hideFirstLast();
});';
$view->registerJs($script);
}
作者:noorafre
项目:makmaka
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
if ($this->content === null) {
return $this->grid->formatter->format($this->getDataCellValue($model, $key, $index), $this->format);
} else {
return parent::renderDataCellContent($model, $key, $index);
}
}
作者:milan01
项目:yii
/**
* Renders the header cell content.
* The default implementation simply renders [[header]].
* This method may be overridden to customize the rendering of the header cell.
* @return string the rendering result
*/
protected function renderHeaderCellContent()
{
if ($this->header !== null || !$this->multiple) {
return parent::renderHeaderCellContent();
} else {
return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
}
}
作者:microingine
项目:yii2-dropdown-action-colum
/**
* Initializes the object.
* This method is invoked at the end of the constructor after the object is initialized with the
* given configuration.
*/
public function init()
{
$this->defaultItems = !$this->items;
parent::init();
}