本文整理汇总了PHP中kartik\dynagrid\DynaGrid::begin方法的典型用法代码示例。如果您正苦于以下问题:PHP DynaGrid::begin方法的具体用法?PHP DynaGrid::begin怎么用?PHP DynaGrid::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kartik\dynagrid\DynaGrid
的用法示例。
在下文中一共展示了DynaGrid::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$columns[] = ['attribute' => $attr, 'format' => ['image', ['width' => '100']], 'value' => function ($model) {
return $model->getImageUrl() ? $model->getImageUrl() : '';
}, 'filter' => false, 'visible' => isset($value['visible']) ? $value['visible'] : true];
break;
case Content::ATTR_TYPE_DATE:
$columns[] = ['attribute' => $attr, 'format' => ['raw', ['width' => '100']], 'value' => function ($data) use($attr) {
return Yii::$app->formatter->asDateTime($data->{$attr}, Yii::$app->formatter->dateFormat) . ' <small style="color:gray;">' . Yii::$app->formatter->asDateTime($data->{$attr}, Yii::$app->formatter->timeFormat) . '</small>';
}, 'filter' => false, 'visible' => isset($value['visible']) ? $value['visible'] : true];
break;
case Content::ATTR_TYPE_BOOLEAN:
$columns[] = ['attribute' => $attr, 'format' => 'raw', 'value' => function ($data) use($attr) {
return Html::checkbox($attr, $data->{$attr});
}, 'filter' => false, 'visible' => isset($value['visible']) ? $value['visible'] : true];
break;
case Content::ATTR_TYPE_DROPDOWN:
$columns[] = ['attribute' => $attr, 'value' => function ($data) use($attr, $value) {
return isset($value['items'][$data->{$attr}]) ? $value['items'][$data->{$attr}] : '';
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $value['items'], 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '---'], 'visible' => isset($value['visible']) ? $value['visible'] : true];
break;
default:
$columns[] = ['attribute' => $attr, 'visible' => isset($value['visible']) ? $value['visible'] : true];
break;
}
}
}
if (class_exists('\\stepancher\\adminlteTheme\\config\\AnminLteThemeConfig')) {
DynaGrid::begin(\yii\helpers\ArrayHelper::merge(\stepancher\adminlteTheme\config\AnminLteThemeConfig::getDefaultConfigDynagrid(), ['columns' => $columns, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['after' => Html::a('<i class="icon glyphicon fa fa-reply"></i>   Восстановить', '#', ['data-classname' => $module::className(), 'data-action' => \stepancher\content\controllers\AdminController::ACTION_UNARCHIVE, 'class' => 'btn btn-primary btn-multiple', 'title' => 'Восстановить выбранные записи']) . Html::a('<i class="icon glyphicon fa fa-trash"></i>   Удалить', '#', ['data-classname' => $module::className(), 'data-action' => \stepancher\content\controllers\AdminController::ACTION_DELETE, 'class' => 'btn btn-danger btn-multiple', 'title' => 'Удалить выбранные записи']) . '<div class="pull-right">{pager}</div>'], 'options' => ['id' => 'grid', 'data-url' => '/admin/' . $this->context->module->id . '/group-action']], 'options' => ['id' => 'dynagrid-archive-' . $this->context->module->id]]));
} else {
DynaGrid::begin(['columns' => $columns, 'toggleButtonGrid' => ['label' => '<i class="glyphicon glyphicon-wrench"></i>   Настройки'], 'toggleButtonFilter' => ['label' => '<i class="glyphicon glyphicon-filter"></i>    Фильтры'], 'toggleButtonSort' => ['label' => '<i class="glyphicon glyphicon-sort"></i>    Сортировка'], 'storage' => DynaGrid::TYPE_DB, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Сбросить', [''], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Обновить'])], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}{toggleData}'], '{export}'], 'export' => ['label' => 'Экспорт'], 'panel' => ['footer' => false, 'after' => Html::a('<i class="icon glyphicon fa fa-reply"></i>   Восстановить', '#', ['data-classname' => $module::className(), 'data-action' => \stepancher\content\controllers\AdminController::ACTION_UNARCHIVE, 'class' => 'btn btn-primary btn-multiple', 'title' => 'Восстановить выбранные записи']) . Html::a('<i class="icon glyphicon fa fa-trash"></i>   Удалить', '#', ['data-classname' => $module::className(), 'data-action' => \stepancher\content\controllers\AdminController::ACTION_DELETE, 'class' => 'btn btn-danger btn-multiple', 'title' => 'Удалить выбранные записи']) . '<div class="pull-right">{pager}</div>'], 'options' => ['id' => 'grid', 'data-url' => '/admin/' . $this->context->module->id . '/group-action']], 'options' => ['id' => 'dynagrid-archive-' . $this->context->module->id]]);
}
DynaGrid::end();
示例2: function
<div class="user-index">
<div class="page-header">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
</div>
<?php
//echo $this->render('_search', ['model' => $searchModel]);
?>
<?php
$toolbars = [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i>', ['user/create'], ['type' => 'button', 'title' => 'Add ' . $this->title, 'class' => 'btn btn-success']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['user/index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid'])], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'], '{export}'];
$panels = ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> ' . $this->title . '</h3>', 'before' => '<div style="padding-top: 7px;"><em>* The table at the right you can pull reports & personalize</em></div>'];
$columns = [['class' => 'kartik\\grid\\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT], 'id', ['attribute' => 'avatar', 'format' => 'html', 'value' => function ($data) {
return $data->thumb;
}], 'username', 'name', 'email', 'phone', 'city', 'position', ['attribute' => 'role', 'filter' => common\models\User::$roles, 'value' => function ($data) {
return common\models\User::$roles[$data->role];
}], ['attribute' => 'createDate', 'value' => function ($data) {
return $data->createDate;
}, 'filterType' => GridView::FILTER_DATE, 'format' => 'raw', 'width' => '100px', 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s']], 'visible' => false], ['attribute' => 'updateDate', 'value' => function ($data) {
return $data->updateDate;
}, 'filterType' => GridView::FILTER_DATE, 'format' => 'raw', 'width' => '100px', 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s']], 'visible' => true], ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'vAlign' => 'middle'], ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => false, 'vAlign' => 'middle', 'viewOptions' => ['title' => 'view', 'data-toggle' => 'tooltip'], 'updateOptions' => ['title' => 'update', 'data-toggle' => 'tooltip'], 'deleteOptions' => ['title' => 'delete', 'data-toggle' => 'tooltip']]];
$dynagrid = DynaGrid::begin(['id' => 'user-grid', 'columns' => $columns, 'theme' => 'panel-primary', 'showPersonalize' => true, 'storage' => 'db', 'allowSortSetting' => true, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showPageSummary' => true, 'floatHeader' => true, 'pjax' => true, 'panel' => $panels, 'toolbar' => $toolbars], 'options' => ['id' => 'user']]);
DynaGrid::end();
?>
</div>
示例3: function
<div class="row">
<div class="col-xs-12">
<div class="box box-primary">
<div class="box-header">
<?php
echo $this->render('_search', ['model' => $searchModel]);
?>
</div>
<!-- /.box-header -->
<div class="box-body">
<?php
$dynagrid = DynaGrid::begin(['storage' => DynaGrid::TYPE_COOKIE, 'gridOptions' => ['dataProvider' => $dataProvider, 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'rowOptions' => function ($model) {
return $model->status ? ['class' => 'success'] : ['class' => 'warning'];
}, 'options' => ['id' => 'grid'], 'floatHeader' => false, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true, 'options' => []], 'persistResize' => false, 'panelAfterTemplate' => '<div class="pull-left" style="padding-top:5px">{summary}</div><div class="pull-right">{button}</div><div class="clearfix"></div>', 'replaceTags' => ['{button}' => function ($model) {
return Html::button('Use Selected With', ['class' => 'btn btn-primary', 'onclick' => 'var keys = $("#grid").yiiGridView("getSelectedRows").length; alert(keys > 0 ? "Selected " + keys + " row, Sorry, The button was disabled" : "No rows selected.");']);
}], 'panel' => ['heading' => false, 'before' => Html::a('<i class="glyphicon glyphicon-import"></i>', ['import'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Import: ' . Html::encode($this->title)]), 'beforeOptions' => ['class' => 'kv-panel-before'], 'afterOptions' => ['class' => 'kv-panel-after clearfix'], 'footer' => Html::tag('span', 'Dump data on Table : ' . Html::tag('strong', Html::encode($this->title))), 'footerOptions' => ['class' => 'panel-footer', 'style' => '']], 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create'], ['data-pjax' => 0, 'class' => 'btn btn-success', 'title' => 'New'])], ['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid'])], ['content' => '{toggleData} {dynagridFilter} {dynagridSort}'], '{dynagrid}', '{export}'], 'export' => ['fontAwesome' => true], 'exportConfig' => [GridView::HTML => ['filename' => Yii::t('kvgrid', 'TestName'), 'alertMsg' => Yii::t('kvgrid', 'The HTML export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Hyper Text Markup Language')]], GridView::CSV => ['filename' => Yii::t('kvgrid', 'TestName'), 'alertMsg' => Yii::t('kvgrid', 'The CSV export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Comma Separated Values')]], GridView::TEXT => ['filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The TEXT export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Tab Delimited Text')]], GridView::EXCEL => ['filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The EXCEL export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Microsoft Excel 95+')], 'config' => ['worksheet' => Yii::t('kvgrid', 'ExportWorksheet'), 'cssFile' => '']], GridView::PDF => ['filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The PDF export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Portable Document Format')], 'config' => ['options' => ['subject' => Yii::t('kvgrid', 'PDF export generated by kartik-v/yii2-grid extension'), 'keywords' => Yii::t('kvgrid', 'krajee, grid, export, yii2-grid, pdf')], 'contentBefore' => '', 'contentAfter' => '']], GridView::JSON => ['filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The JSON export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'JavaScript Object Notation')]]]], 'options' => ['id' => 'dynagrid-1'], 'columns' => ArrayHelper::merge([['class' => 'kartik\\grid\\SerialColumn', 'header' => Html::encode('No'), 'order' => DynaGrid::ORDER_FIX_LEFT, 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column']]], $columns, [['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column'], 'editableOptions' => function ($model, $key, $index, $widget) {
return ['inputType' => Editable::INPUT_SELECT2, 'type' => Editable::FORMAT_LINK, 'size' => 'md', 'options' => ['class' => 'form-control', 'initValueText' => '', 'data' => $model->getStatusLabels(), 'options' => ['placeholder' => $model->status ? 'Active' : 'Inactive'], 'pluginOptions' => ['allowClear' => true]]];
}, 'value' => function ($model, $key, $index, $widget) {
return $model->status ? 'Active ' : 'Inactive';
}], ['attribute' => 'created_at', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'noWrap' => true, 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column'], 'format' => ['date', 'php:Y-m-d H:i:s']], ['attribute' => 'updated_at', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'noWrap' => true, 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column'], 'format' => ['date', 'php:Y-m-d H:i:s']], ['class' => 'kartik\\grid\\ActionColumn', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'noWrap' => true, 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column'], 'viewOptions' => ['title' => '', 'data-toggle' => 'tooltip', 'class' => "btn btn-primary"], 'updateOptions' => ['title' => '', 'data-toggle' => 'tooltip', 'class' => "btn btn-default"], 'deleteOptions' => ['title' => '', 'data-toggle' => 'tooltip', 'class' => 'btn btn-danger'], 'order' => DynaGrid::ORDER_FIX_RIGHT], ['class' => 'kartik\\grid\\CheckboxColumn', 'order' => DynaGrid::ORDER_FIX_RIGHT]])]);
if (substr($dynagrid->theme, 0, 6) == 'simple') {
$dynagrid->gridOptions['panel'] = false;
}
DynaGrid::end();
?>
</div><!-- /.box-body -->
<!--
<div class="box-footer"></div>
-->
</div><!-- /.box -->
</div><!-- /.col -->
示例4: function
$this->title = Module::t('comments', 'BACKEND_INDEX_TITLE');
$this->params['subtitle'] = Module::t('comments', 'BACKEND_INDEX_SUBTITLE');
$this->params['breadcrumbs'] = [$this->title];
$columns = [['class' => 'kartik\\grid\\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT], 'parent_id', 'model_id', ['attribute' => 'model_class', 'value' => function ($model) {
return $model->class->name;
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $modelArray, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '---']], 'content', ['attribute' => 'status_id', 'format' => 'html', 'value' => function ($model) {
$class = 'label-success';
switch ($model->status_id) {
case $model::STATUS_ACTIVE:
$class = 'label-success';
break;
case $model::STATUS_MODER:
$class = 'label-warning';
break;
default:
$class = 'label-danger';
break;
}
return '<span class="label ' . $class . '">' . $model->status . '</span>';
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $statusArray, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '---']], ['attribute' => 'created_at', 'format' => 'date'], ['attribute' => 'updated_at', 'format' => 'date'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '<nobr>{update}{delete}</nobr>', 'buttons' => ['update' => function ($url, $model) {
return Html::a('<span class="icon fa fa-edit"></span>', $url, ['class' => 'btn btn-sm btn-primary']);
}, 'delete' => function ($url, $model) {
return Html::a('<span class="icon fa fa-trash"></span>', $url, ['class' => 'btn btn-sm btn-danger isDel', 'data-method' => 'post', 'data-pjax' => 0]);
}]]];
$dynaGridOptions = ['columns' => $columns, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['after' => '<div class="pull-right">{pager}</div>']], 'options' => ['id' => 'dynagrid-comments']];
if (class_exists('\\stepancher\\adminlteTheme\\config\\AnminLteThemeConfig')) {
DynaGrid::begin(\yii\helpers\ArrayHelper::merge(\stepancher\adminlteTheme\config\AnminLteThemeConfig::getDefaultConfigDynagrid(), $dynaGridOptions));
} else {
DynaGrid::begin(['columns' => $columns, 'toggleButtonGrid' => ['label' => '<i class="glyphicon glyphicon-wrench"></i>   Настройки'], 'toggleButtonFilter' => ['label' => '<i class="glyphicon glyphicon-filter"></i>    Фильтры'], 'toggleButtonSort' => ['label' => '<i class="glyphicon glyphicon-sort"></i>    Сортировка'], 'storage' => DynaGrid::TYPE_DB, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Сбросить', [''], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Обновить'])], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}{toggleData}'], '{export}'], 'export' => ['label' => 'Экспорт'], 'panel' => ['after' => false]], 'options' => ['id' => 'dynagrid-comments']]);
}
DynaGrid::end();
示例5: function
<?php
$toolbars = [['content' => Html::button('<i class="fa fa-question-circle"></i> 操作指引', ['type' => 'button', 'title' => '操作指引-' . $this->title, 'class' => 'btn btn-warning', 'id' => 'helpButton']) . ' ' . Html::button('<i class="fa fa-history"></i> 恢复记录', ['type' => 'button', 'title' => '恢复记录-' . $this->title, 'class' => 'btn btn-success', 'id' => 'retrieveSelected']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['event/history', 'p_reset' => true], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid']) . ' '], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'], '{export}'];
$panels = ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> ' . $this->title . '</h3>', 'before' => '<div style="padding-top: 7px;"><em>* 右边可以导出各种格式并对表格进行个性化设置</em></div>'];
$columns = [['class' => '\\kartik\\grid\\CheckboxColumn', 'checkboxOptions' => ['class' => 'simple'], 'rowSelectedClass' => GridView::TYPE_SUCCESS, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'width' => '5%'], ['class' => 'kartik\\grid\\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT, 'width' => '5%'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '5%', 'value' => function ($model, $key, $index, $column) {
return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
//return Yii::$app->controller->renderPartial('_details', ['model'=>$model]);
return $model->old_value;
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true], ['attribute' => 'model_id', 'header' => '事件ID', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $key, $index, $column) {
return $model->model_id ? Html::a($model->model_id, ['audit/entry/view', 'id' => $model->entry_id], ['target' => '_blank']) : '';
}, 'format' => 'raw', 'width' => '6%'], ['attribute' => 'user_id', 'header' => '操作人员', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $key, $index, $column) {
return \dektrium\user\models\User::findOne($model->user_id)->username;
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\dektrium\user\models\User::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '操作人员'], 'format' => 'raw', 'width' => '10%'], ['attribute' => 'created', 'header' => '删除时间', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd', 'todayHighlight' => true, 'autoclose' => true]], 'format' => 'datetime', 'width' => '15%'], ['attribute' => 'old_value', 'header' => '删除内容', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'format' => 'raw', 'width' => '54%', 'content' => function ($model, $key, $index, $column) {
return "<div class='event_old_value'>{$model->old_value}</div>";
}]];
$dynagrid = DynaGrid::begin(['id' => 'event-history-grid', 'columns' => $columns, 'theme' => 'panel-primary', 'showPersonalize' => true, 'storage' => 'db', 'allowSortSetting' => true, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showPageSummary' => true, 'floatHeader' => true, 'pjax' => true, 'panel' => $panels, 'toolbar' => $toolbars, 'hover' => true], 'options' => ['id' => 'Event-history-' . Yii::$app->user->identity->id]]);
DynaGrid::end();
?>
</div>
<?php
\common\widgets\JsBlock::begin();
?>
<script type="text/javascript">
$(function(){
/*var content = "<ul>恢复操作指引<li><font color='red'>删除内容</font>中输入内容筛选</li><li>点击复选框选中需要恢复的记录</li><li>点击按钮恢复记录</li></ul>";
layer.msg(content, {
shift: 0,
icon: 6,
time: 20000
});*/
$('.event_old_value').slimScroll({