本文整理汇总了PHP中yii\grid\Column::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::init方法的具体用法?PHP Column::init怎么用?PHP Column::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\grid\Column
的用法示例。
在下文中一共展示了Column::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: 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);
}
示例3: 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.');
}
}
示例4: 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();
}
示例5: 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;
}
}
示例6: 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.');
}
if (substr($this->name, -2) !== '[]') {
$this->name .= '[]';
}
}
示例7: 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.');
}
if (substr_compare($this->name, '[]', -2, 2)) {
$this->name .= '[]';
}
$this->registerClientScript();
}
示例8: 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;
}
示例9: 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);
}
示例10: init
public function init()
{
parent::init();
$this->initDefaultButtons();
}
示例11: init
/**
* @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();
}
示例12: 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()
{
$this->defaultItems = !$this->items;
parent::init();
}
示例13: init
public function init()
{
parent::init();
$this->header = Yii::t('easyii', 'Status');
}
示例14: init
public function init()
{
parent::init();
$this->initDefaultItems();
}
示例15: init
public function init(){
if(!class_exists($this->modelClass)){
throw new HttpException(400, 'Model Class Must Be Set');
}
parent::init();
}