本文整理汇总了PHP中yii\grid\Column类的典型用法代码示例。如果您正苦于以下问题:PHP Column类的具体用法?PHP Column怎么用?PHP Column使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHeaderCellContent
/**
* 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']);
}
}
示例2: init
/**
* @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();
}
}
示例3: renderFilterCellContent
protected function renderFilterCellContent()
{
$filter = $this->guessFilter();
if ($filter instanceof BaseFilter) {
return $filter->render();
}
return Column::renderFilterCellContent();
}
示例4: renderHeaderCellContent
/**
* 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();
}
}
示例5: function
<?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>
示例6: function
<?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' => 'Дата']]]);
示例7: renderHeaderCellContent
/**
* 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']);
}
}
示例8: renderHeaderCellContent
/**
* 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>";
}
}
示例9: init
/**
* @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.');
}
}
示例10: init
/**
* @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);
}
示例11: init
/**
* 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();
}
示例12: init
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;
}
}
示例13: renderHeaderCellContent
/**
* @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();
}
示例14: init
/**
* @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;
}
示例15: init
/**
* @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);
}