/** * @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(); } }
/** * @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); }
/** * @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.'); } }
/** * 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(); }
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; } }
/** * @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.'); } if (substr($this->name, -2) !== '[]') { $this->name .= '[]'; } }
/** * @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.'); } if (substr_compare($this->name, '[]', -2, 2)) { $this->name .= '[]'; } $this->registerClientScript(); }
/** * @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; }
/** * @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); }
public function init() { parent::init(); $this->initDefaultButtons(); }
/** * @inheritdoc */ public function init() { if (empty($this->name)) { throw new InvalidConfigException('The "name" property must be set.'); } $css = $this->rowHighlight ? $this->rowSelectedClass : ''; $this->_view = $this->grid->getView(); RadioColumnAsset::register($this->_view); $grid = $this->grid->options['id']; $this->_clientVars = "'{$grid}', '{$this->name}', '{$css}'"; $this->_clientScript = "kvSelectRadio({$this->_clientVars});"; $this->_view->registerJs($this->_clientScript); $this->parseFormat(); $this->parseVisibility(); parent::init(); $this->setPageRows(); }
/** * 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(); }
public function init() { parent::init(); $this->header = Yii::t('easyii', 'Status'); }
public function init() { parent::init(); $this->initDefaultItems(); }
public function init(){ if(!class_exists($this->modelClass)){ throw new HttpException(400, 'Model Class Must Be Set'); } parent::init(); }
/** * @inheritdoc */ public function init() { parent::init(); $this->contentOptions = array_merge($this->contentOptions, ['width' => 90]); $this->initDefaultButtons(); if (!$this->checkaccess) { $this->checkaccess = function ($url) { return true; }; } }
/** * @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.'); } if (substr($this->name, -2) !== '[]') { $this->name .= '[]'; } $this->initDefaultButtons(); if (!$this->checkaccess) { $this->checkaccess = function ($url) { return true; }; } }
public function init(){ parent::init(); }