init() public method

public init ( )
示例#1
0
 public function init()
 {
     parent::init();
     if ($this->nestable === true || is_array($this->nestable)) {
         echo $this->nestableGrid();
     }
 }
示例#2
0
 public function init()
 {
     if (!is_null($this->gridHookName)) {
         $this->getHookData();
     }
     parent::init();
 }
示例#3
0
 function init()
 {
     parent::init();
     if (!isset($this->replaceTags['{fullExport}'])) {
         $this->replaceTags['{fullExport}'] = ExcelMenu::widget(['dataProvider' => $this->dataProvider, 'filterModel' => $this->filterModel, 'columns' => $this->_columns, 'asDropdown' => $this->asButtonDropdown, 'exportConfig' => $this->exportMenu, 'showConfirmAlert' => false, 'target' => ExportMenu::TARGET_BLANK, 'filename' => $this->filename ?: $this->view->title ?: 'grid-export', 'enableFormatter' => false]);
     }
 }
示例#4
0
 /**
  * Inits widget
  */
 public function init()
 {
     parent::init();
     $this->initPager();
     $this->initVisible();
     $this->initSortable();
     //GridViewAsset::register($this->view);
 }
示例#5
0
 /**
  * (non-PHPdoc)
  * @see \kartik\grid\GridView::init()
  */
 public function init()
 {
     if (!isset($this->templateName)) {
         throw InvalidConfigException("Property tamplateName need to be set.");
     }
     $this->template_name = $this->templateName;
     $this->initTemplate();
     $this->prepareColumns();
     $this->prepareToolBar();
     $this->pjax = true;
     $this->pjaxSettings['options'] = ['id' => 'flexible-grid-pjax'];
     parent::init();
     $this->_module = Config::initModule(Module::classname());
 }
 public function init()
 {
     parent::init();
     $classes = isset($this->options['class']) ? $this->options['class'] : '';
     $classes .= ' sortable';
     $this->options['class'] = trim($classes);
     $view = $this->getView();
     JuiAsset::register($view);
     $url = Url::toRoute($this->orderUrl);
     $sortOpts = array_merge($this->sortOptions, ['axis' => 'y', 'helper' => new JsExpression('function(e, ui) {
             ui.children().each(function() {
                $(this).width($(this).width());
             });
             return ui;
         }'), 'update' => new JsExpression("function(e, ui) {\n                jQuery('#{$this->id}').addClass('sorting');\n                jQuery.ajax({\n                    type: 'POST',\n                    url: '{$url}',\n                    data: {\n                        key: ui.item.data('key'),\n                        pos: ui.item.index()\n                    },\n                    complete: function() {\n                        jQuery('#{$this->id}').removeClass('sorting');\n                    }\n                });\n            }")]);
     $sortJson = Json::encode($sortOpts);
     $id = $this->getId();
     $view->registerJs("var id = {$id}; var sortJson = {$sortJson}; jQuery('#{$id} tbody').sortable({$sortJson});");
 }
示例#7
0
 public function init()
 {
     $this->registerTranslations();
     //Toolbar
     $toolbar = ['{export}', '{toggleData}'];
     $view = $this->getView();
     $basic_toolbar = [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . self::t('toolbar', 'Add'), ['update'], ['data-pjax' => 0, 'title' => 'Add Pages', 'class' => 'btn btn-success']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . self::t('toolbar', 'Refresh'), ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid'])]];
     if ($this->filterModel->hasAttribute('category_id') || $this->filterModel->hasMethod('getCategory')) {
         array_push($basic_toolbar, ['content' => Html::a('<i class="glyphicon glyphicon-list"></i> ' . self::t('toolbar', 'Categories'), [\Yii::$app->controller->id . '-category/list'], ['data-pjax' => 0, 'title' => 'Categories', 'class' => 'btn btn-default'])]);
     }
     if ($this->filterModel->hasAttribute($this->filterModel->removedAttribute)) {
         array_push($basic_toolbar, ['content' => Html::a('<i class="glyphicon glyphicon-trash"></i> ' . self::t('toolbar', 'In Trash'), ['trash'], ['data-pjax' => 0, 'title' => 'Removed records', 'class' => 'btn btn-default'])]);
     }
     if ($view->context->action->id === 'trash') {
         $basic_toolbar = [['content' => Html::a('<i class="glyphicon glyphicon-arrow-left"></i> ' . self::t('toolbar', 'Back to Records'), ['list'], ['data-pjax' => 0, 'title' => 'List records', 'class' => 'btn btn-default'])]];
     }
     $toolbar = \yii\helpers\ArrayHelper::merge($basic_toolbar, $toolbar);
     $this->toolbar = $toolbar;
     return parent::init();
     // TODO: Change the autogenerated stub
 }
示例#8
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (empty($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if (empty($this->exportRequestParam)) {
         $this->exportRequestParam = 'exportFull_' . $this->options['id'];
     }
     $this->_columnSelectorEnabled = $this->showColumnSelector && $this->asDropdown;
     $this->_triggerDownload = !empty($_POST) && !empty($_POST[$this->exportRequestParam]) && $_POST[$this->exportRequestParam];
     $this->_doNotStream = !$this->stream && !$this->streamAfterSave;
     if ($this->_doNotStream) {
         $this->target = self::TARGET_SELF;
     }
     if ($this->_triggerDownload) {
         if (!$this->_doNotStream) {
             Yii::$app->controller->layout = false;
         }
         $this->_exportType = $_POST[self::PARAM_EXPORT_TYPE];
         $this->_columnSelectorEnabled = $_POST[self::PARAM_COLSEL_FLAG];
         $this->initSelectedColumns();
     }
     parent::init();
 }
示例#9
0
文件: GridView.php 项目: letyii/cms
 public function init()
 {
     return parent::init();
 }
示例#10
0
 public function init()
 {
     Yii::setAlias('@excelview', dirname(__FILE__));
     Yii::$app->i18n->translations['excelview'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@excelview/messages', 'forceTranslation' => true];
     if ($this->fullExport !== false) {
         $this->fullExport = ArrayHelper::merge(['label' => Yii::t('excelview', 'Full Export'), 'icon' => 'export', 'browserPopupsMsg' => Yii::t('excelview', 'Disable any popup blockers in your browser to ensure proper download.'), 'options' => ['class' => 'btn btn-danger']], $this->export);
         $defaultExportConfig = [self::FULL_HTML => ['label' => Yii::t('excelview', 'HTML'), 'icon' => 'floppy-saved', 'filename' => Yii::t('excelview', 'grid-export'), 'options' => ['title' => Yii::t('excelview', 'Save as HTML')], 'Content-type' => 'text/html', 'extension' => 'html', 'PHPExcel_Writer' => 'HTML', 'header' => true], self::FULL_CSV => ['label' => Yii::t('excelview', 'CSV'), 'icon' => 'floppy-open', 'colDelimiter' => ",", 'rowDelimiter' => "\r\n", 'filename' => Yii::t('excelview', 'grid-export'), 'options' => ['title' => Yii::t('excelview', 'Save as CSV')], 'Content-type' => 'application/csv', 'extension' => 'csv', 'PHPExcel_Writer' => 'CSV', 'header' => false], self::FULL_PDF => ['label' => Yii::t('excelview', 'PDF'), 'icon' => 'floppy-save', 'filename' => Yii::t('excelview', 'grid-export'), 'options' => ['title' => Yii::t('excelview', 'Save as PDF')], 'Content-type' => 'application/pdf', 'extension' => 'pdf', 'PHPExcel_Writer' => 'PDF', 'header' => true], self::FULL_EXCEL => ['label' => Yii::t('excelview', 'Excel 95 and above'), 'icon' => 'floppy-remove', 'worksheet' => Yii::t('excelview', 'ExportWorksheet'), 'filename' => Yii::t('excelview', 'grid-export'), 'cssFile' => '', 'options' => ['title' => Yii::t('excelview', 'Save as Excel (xls)')], 'Content-type' => 'application/vnd.ms-excel', 'extension' => 'xls', 'PHPExcel_Writer' => 'Excel5', 'header' => true], self::FULL_EXCELX => ['label' => Yii::t('excelview', 'Excel 2007 and above'), 'icon' => 'floppy-remove', 'worksheet' => Yii::t('excelview', 'ExportWorksheet'), 'filename' => Yii::t('excelview', 'grid-export'), 'cssFile' => '', 'options' => ['title' => Yii::t('excelview', 'Save as Excel (xlsx)')], 'Content-type' => 'application/vnd.ms-excel', 'extension' => 'xlsx', 'PHPExcel_Writer' => 'Excel2007', 'header' => true]];
         if (is_array($this->fullExportConfig) && !empty($this->fullExportConfig)) {
             foreach ($this->fullExportConfig as $format => $setting) {
                 $setup = is_array($this->fullExportConfig[$format]) ? $this->fullExportConfig[$format] : [];
                 $exportConfig[$format] = empty($setup) ? $defaultExportConfig[$format] : ArrayHelper::merge($defaultExportConfig[$format], $setup);
             }
             $this->fullExportConfig = $exportConfig;
         } else {
             $this->fullExportConfig = $defaultExportConfig;
         }
         foreach ($this->fullExportConfig as $format => $setting) {
             $this->fullExportConfig[$format]['options']['data-pjax'] = false;
         }
     }
     $params = \Yii::$app->request->queryParams;
     if (isset($params[$this->grid_mode_var])) {
         $this->grid_mode = $params[$this->grid_mode_var];
     }
     if (isset($params['exportType'])) {
         $this->fullExportType = $params['exportType'];
     }
     if ($this->grid_mode == 'export') {
         #$this->title = $this->title ? $this->title : \yii\web\View::$title;
         $module = Yii::$app->getModule('gridview');
         $this->initColumns();
         //parent::init();
         //Autoload fix
         #            spl_autoload_unregister(array('YiiBase', 'autoload'));
         #            Yii::import($this->libPath, true);
         $this->objPHPExcel = new \PHPExcel();
         #            spl_autoload_register(array('YiiBase', 'autoload'));
         // Creating a workbook
         $this->objPHPExcel->getProperties()->setCreator($this->creator);
         $this->objPHPExcel->getProperties()->setTitle($this->title);
         $this->objPHPExcel->getProperties()->setSubject($this->subject);
         $this->objPHPExcel->getProperties()->setDescription($this->description);
         $this->objPHPExcel->getProperties()->setCategory($this->category);
     } else {
         parent::init();
     }
 }
示例#11
0
文件: GridView.php 项目: nagser/base
 public function init()
 {
     parent::init();
 }
示例#12
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->_columnSelectorEnabled = $this->showColumnSelector && $this->asDropdown;
     $this->_triggerDownload = !empty($_POST) && !empty($_POST[$this->exportRequestParam]) && $_POST[$this->exportRequestParam];
     if ($this->_triggerDownload) {
         Yii::$app->controller->layout = false;
         $this->_exportType = $_POST[self::PARAM_EXPORT_TYPE];
         $this->_columnSelectorEnabled = $_POST[self::PARAM_COLSEL_FLAG];
         $this->initSelectedColumns();
     }
     parent::init();
 }
示例#13
0
 public function init()
 {
     $module = Yii::$app->getModule('gridview');
     if ($module == null || !$module instanceof \kartik\grid\Module) {
         throw new InvalidConfigException('The "gridview" module MUST be setup in your Yii configuration file and assigned to "\\kartik\\grid\\Module" class.');
     }
     if ($this->export !== false) {
         $this->export = ArrayHelper::merge(['label' => Yii::t('kvgrid', 'Export'), 'icon' => 'export', 'browserPopupsMsg' => Yii::t('kvgrid', 'Disable any popup blockers in your browser to ensure proper download.'), 'options' => ['class' => 'btn btn-danger']], $this->export);
         $defaultExportConfig = [self::HTML => ['label' => Yii::t('kvgrid', 'HTML'), 'icon' => 'floppy-saved', 'showHeader' => true, 'showPageSummary' => true, 'showFooter' => true, 'showCaption' => true, 'filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The HTML export file will be generated for download.'), 'cssFile' => 'http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css', 'options' => ['title' => Yii::t('kvgrid', 'Save as HTML')]], self::CSV => ['label' => Yii::t('kvgrid', 'CSV'), 'icon' => 'floppy-open', 'showHeader' => true, 'showPageSummary' => true, 'showFooter' => true, 'showCaption' => true, 'colDelimiter' => ",", 'rowDelimiter' => "\r\n", 'filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The CSV export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Save as CSV')]], self::TEXT => ['label' => Yii::t('kvgrid', 'Text'), 'icon' => 'floppy-save', 'showHeader' => true, 'showPageSummary' => true, 'showFooter' => true, 'showCaption' => true, 'colDelimiter' => "\t", 'rowDelimiter' => "\r\n", 'filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The TEXT export file will be generated for download.'), 'options' => ['title' => Yii::t('kvgrid', 'Save as Text')]], self::EXCEL => ['label' => Yii::t('kvgrid', 'Excel'), 'icon' => 'floppy-remove', 'showHeader' => true, 'showPageSummary' => true, 'showFooter' => true, 'showCaption' => true, 'worksheet' => Yii::t('kvgrid', 'ExportWorksheet'), 'filename' => Yii::t('kvgrid', 'grid-export'), 'alertMsg' => Yii::t('kvgrid', 'The EXCEL export file will be generated for download.'), 'cssFile' => '', 'options' => ['title' => Yii::t('kvgrid', 'Save as Excel')]]];
         $exportConfig = [];
         if (is_array($this->exportConfig) && !empty($this->exportConfig)) {
             foreach ($this->exportConfig as $format => $setting) {
                 $setup = is_array($this->exportConfig[$format]) ? $this->exportConfig[$format] : [];
                 $exportConfig[$format] = empty($setup) ? $defaultExportConfig[$format] : ArrayHelper::merge($defaultExportConfig[$format], $setup);
             }
             $this->exportConfig = $exportConfig;
         } else {
             $this->exportConfig = $defaultExportConfig;
         }
     }
     if ($this->filterPosition === self::FILTER_POS_HEADER) {
         // Float header plugin misbehaves when Filter is placed on the first row
         // So disable it when `filterPosition` is `header`.
         $this->floatHeader = false;
     }
     if ($this->bootstrap) {
         Html::addCssClass($this->tableOptions, 'table');
         if ($this->hover) {
             Html::addCssClass($this->tableOptions, 'table-hover');
         }
         if ($this->bordered) {
             Html::addCssClass($this->tableOptions, 'table-bordered');
         }
         if ($this->striped) {
             Html::addCssClass($this->tableOptions, 'table-striped');
         }
         if ($this->condensed) {
             Html::addCssClass($this->tableOptions, 'table-condensed');
         }
     }
     parent::init();
     $this->registerAssets();
 }
示例#14
0
 public function init()
 {
     if ($this->panel) {
         $this->bordered = false;
         $this->condensed == true;
         $this->presetPanelIcon();
     }
     if ($this->resizableColumns && $this->persistResize) {
         // set the default resizeStorageKey
         $this->resizeStorageKey = Yii::$app->user->id . '-' . date("m");
     }
     // enable first and last pager button
     $this->pager = ['prevPageLabel' => '&lt;', 'nextPageLabel' => '&gt;', 'firstPageLabel' => '<< First', 'lastPageLabel' => 'Last >>'];
     /*
     $this->toolbar = [
         ['content'=>
             Html::button('<i class="glyphicon glyphicon-plus"></i>', ['type'=>'button', 'title'=>Yii::t('kvgrid', 'Add Book'), 'class'=>'btn btn-success', 'onclick'=>'alert("This will launch the book creation form.\n\nDisabled for this demo!");']) . ' '.
             Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['grid-demo'], ['data-pjax'=>0, 'class' => 'btn btn-default', 'title'=>Yii::t('kvgrid', 'Reset Grid')])
         ],
         '{export}',
         '{toggleData}',
     ];
     */
     parent::init();
     $this->export = ArrayHelper::merge(['label' => Yii::t('kvgrid', 'Export'), 'icon' => 'export', 'browserPopupsMsg' => Yii::t('kvgrid', 'Disable any popup blockers in your browser to ensure proper download.'), 'options' => ['class' => 'btn btn-danger']], $this->export);
 }
 public function init()
 {
     parent::init();
     $this->sortableAction = Url::to($this->sortableAction);
 }
示例#16
0
 public function init()
 {
     parent::init();
     $this->tableOptions = ['class' => 'table table-bordered table-striped'];
     $this->toolbar = [['content' => Html::button('<i class="glyphicon glyphicon-plus"></i>', ['type' => 'button', 'title' => Yii::t('app', 'Create'), 'class' => 'btn btn-success']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('app', 'Refresh')])], '{export}', '{toggleData}'];
 }