public function renderTableBody() { if (!empty($this->mergeColumns) || !empty($this->extraRowColumns)) { $this->groupByColumns(); } parent::renderTableBody(); }
/** * Init the widget */ public function init() { parent::init(); $classes = array('table'); if ($this->bordered) { $classes[] = 'table-bordered'; } if ($this->striped) { $classes[] = 'table-striped'; } if ($this->condensed) { $classes[] = 'table-condensed'; } EBootstrap::mergeClassString($this->itemsCssClass, $classes); EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-grid-view')); switch ($this->pagerAlign) { case 'centered': EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-centered')); break; case 'right': EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-right')); break; } if ($this->cssFile === false) { $cssFile = dirname(__FILE__) . '/css/bootstrap.css'; $this->cssFile = Yii::app()->getAssetManager()->publish($cssFile); Yii::app()->clientScript->registerCssFile($this->cssFile); } }
public function init() { $this->displayVar = $this->getId() . 'display'; $this->pageVar = $this->getId() . 'page'; $this->sortVar = $this->getId() . 'sort'; $this->enablePagination = true; $this->enableSorting = true; $this->dataProvider->getPagination()->setPageSize(Yii::app()->request->getParam($this->getId() . 'display') ? Yii::app()->request->getParam($this->getId() . 'display') : 50); $this->dataProvider->getPagination()->pageVar = $this->getId() . 'page'; $display = Yii::app()->request->getParam($this->displayVar); $this->ajaxUpdate = false; $this->summaryText = ' <ul> <li>' . Yii::t('menu', 'Всего') . ': {count}</li> </ul>'; $data = $this->dataProvider; $pagerBlock = $data->getTotalItemCount() > 50 ? '<div class="pager-block"> <div class="left">{summary}</div> <div class="right">{pager}</div> </div>' : null; $this->template = '<div class="table-block">{items}</div>' . $pagerBlock; $this->dataProvider->getSort()->sortVar = $this->sortVar; $this->pager = array('header' => '', 'cssFile' => '', 'class' => 'MyCLinkPager', 'pageVar' => $this->pageVar, 'displayVar' => $this->displayVar, 'prevPageLabel' => '', 'nextPageLabel' => '', 'maxButtonCount' => '5'); parent::init(); }
private function getWidgetScript($callback1, $callback2, $callback3, $callback4) { Yii::import('zii.widgets.grid.CGridView'); Yii::app()->clientScript->scripts = array(); ob_start(); $widget = new CGridView(null); $widget->beforeAjaxUpdate = $callback1; $widget->afterAjaxUpdate = $callback2; $widget->ajaxUpdateError = $callback3; $widget->selectionChanged = $callback4; $widget->dataProvider = new CArrayDataProvider(array(1, 2, 3)); $widget->init(); $widget->registerClientScript(); Yii::app()->clientScript->render($out); ob_end_clean(); return $out; }
/** * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as $i => $column) { if (is_array($column) && !isset($column['class'])) { $this->columns[$i]['class'] = '\\TbDataColumn'; } } parent::initColumns(); }
public function init() { $this->pager = array('class' => 'itemPaginator'); if (Yii::app()->theme->name == 'atlas') { $this->pager = array('class' => 'itemPaginatorAtlas', 'header' => '', 'selectedPageCssClass' => 'current', 'htmlOptions' => array('class' => '')); $this->pagerCssClass = 'pagination'; } parent::init(); }
public function init() { $themeUrl = Yii::app()->theme->baseUrl; $this->cssFile = $themeUrl . '/css/grid.css'; $this->template = '{items}' . "\n" . '{pager}' . "\n" . '{summary}'; //$this->beforeAjaxUpdate = 'js:function(id, data){ alertify.log("loading grid data... please wait..."); }'; //$this->afterAjaxUpdate = 'js:function(id,options){ alertify.log("grid data successfully loaded","success"); }'; return parent::init(); }
/** * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as &$column) { if (!isset($column['class'])) { $column['class'] = 'BootDataColumn'; } } parent::initColumns(); }
protected function initColumns() { parent::initColumns(); if ($this->filter !== null and $this->filterCleanColumn) { //Adiciona coluna para limpar filtros $this->htmlOptions['class'] .= ' hasFilter'; $this->addCleanFiltersColumn(); } }
/** * Initializes the view. */ public function init() { if ($this->enablePagination === false) { $this->dataProvider->setPagination(false); } if ($this->enableAlphaPagination && $this->dataProvider->getAlphaPagination() === false) { $this->enableAlphaPagination = false; } parent::init(); }
/** * Renders the data items for the grid view. */ public function renderItems() { if ($this->extended && $this->filter) { $this->insertDropdownHtml(); $this->insertModelAttributes(); } parent::renderItems(); if ($this->enableCustomActions === true) { $this->widget('zii.widgets.CMenu', array('id' => $this->getId() . 'Actions', 'htmlOptions' => array('class' => 'gridFooterActions'), 'items' => $this->getCustomActions())); } }
public function init() { $this->cssFile = false; $this->rowCssClass = array('row1', 'row2'); $this->pager = array('htmlOptions' => array('class' => 'ui-pagination'), 'cssFile' => false, 'header' => false); $this->pagerCssClass = 'option'; $this->template = '<div class="table-options">{pager}{summary}<span class="clear"><!-- --></span></div><div class="table full-width">{items}</div><div class="table-options">{pager}{summary}<span class="clear"><!-- --></span></div>'; $this->summaryCssClass = false; $this->summaryText = 'Результаты <strong class="results-start">{start}</strong>-<strong class="results-end">{end}</strong> из <strong class="results-total">{count}</strong>'; parent::init(); }
/** * Registers necessary client scripts. * Automaticlly prepend user's beforeajaxUpdate with needed code that will modify GET params when navigating and sorting */ public function registerClientScript() { parent::registerClientScript(); if ($this->selectableRows > 0) { $id = $this->getId(); $options = array('selVar' => $this->selVar); $options = CJavaScript::encode($options); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($this->selBaseScriptUrl . '/jquery.selgridview.js', CClientScript::POS_END); $cs->registerScript(__CLASS__ . '#' . $id . '-sel', "jQuery('#{$id}').selGridView({$options});"); } }
/** * Registers necessary client scripts. */ public function registerClientScript() { parent::registerClientScript(); $cs=Yii::app()->getClientScript(); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.core.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.widget.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.mouse.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.droppable.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.draggable.min.js',CClientScript::POS_END); $baseUrl = Y::curBaseUrl(); $cs->registerScript('draganddrop', ' $(document).ready(function() { $("#'.$this->getId().' tbody tr").live("mouseenter", function() { var $this = $(this); if($this.is(":data(draggable)")) return; $this.draggable({ helper: "clone", opacity: .75, refreshPositions: true, // Performance? revert: "invalid", revertDuration: 300, scroll: true }); }); $("#'.$this->getId().' tbody tr").live("mouseenter", function() { var $this = $(this); if ($this.is(":data(droppable)")) return; $(this).droppable({ drop: function(e, ui) { $("#'.$this->getId().'").addClass("grid-views-loading"); $.get( "'.$baseUrl.'/movePosition", { pk : $(ui.draggable).attr("id"), to : $(this).attr("id") }, function() { $.fn.yiiGridView.update("'.$this->getId().'"); } ); }, hoverClass: "accept", }); }); }); '); }
public function init() { $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle(); parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import('application.extensions.phpexcel.Classes.PHPExcel', 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); }
public function init() { parent::init(); $this->url = Yii::app()->getController()->createUrl('sort'); $this->model_name = get_class($this->filter); $this->rowCssClassExpression = '"items[]_{$data->id}"'; $cond = ''; if (!empty($this->cond_attr)) { $attr = $this->cond_attr; $value = $this->filter->{$attr}; $cond = ",attr:'" . $attr . "',value:'" . $value . "'"; } $str_js = "\n var fixHelper = function(e, ui) {\n ui.children().each(function() {\n \$(this).width(\$(this).width());\n });\n return ui;\n };\n\n \$('#" . $this->id . " table.items tbody').sortable({\n forcePlaceholderSize: true,\n forceHelperSize: true,\n items: 'tr',\n update : function (event,ui) {\n\n var el_index = ui.item.index();\n var el_class = ui.item.attr('class');\n var tmp = el_class.split('_');\n var el_id = tmp[1];\n\n\n \$.ajax({\n 'url': '" . $this->url . "',\n 'type': 'post',\n 'data': {index:el_index,id:el_id,model:'" . $this->model_name . "'" . $cond . "},\n 'success': function(data){\n //alert(data);\n \$('#" . $this->id . " table.items tbody tr:even').css('background','#eee');\n \$('#" . $this->id . " table.items tbody tr:odd').css('background','#F8F8F8');\n },\n 'error': function(request, status, error){\n //alert('We are unable to set the sort order at this time. Please try again in a few minutes.');\n }\n });\n },\n helper: fixHelper\n }).disableSelection();\n\n \$('#" . $this->id . " table.items tbody tr:even').css('background','#eee');\n \$('#" . $this->id . " table.items tbody tr:odd').css('background','#F8F8F8');\n "; Yii::app()->clientScript->registerScript('sortable-project', $str_js); Yii::app()->clientScript->registerCoreScript('jquery.ui'); }
public function init() { if (!isset($this->title)) { $this->title = Yii::app()->getController()->getPageTitle(); } parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import(self::$phpExcelPathAlias, true); self::$objPHPExcel = new PHPExcel(); self::$activeSheet = self::$objPHPExcel->getActiveSheet(); spl_autoload_register(array('YiiBase', 'autoload')); // Creating a workbook $properties = self::$objPHPExcel->getProperties(); $properties->setTitle($this->title)->setCreator($this->creator)->setSubject($this->subject)->setDescription($this->description)->setCategory($this->category); //$this->initColumns(); }
public function initColumns() { if ($this->sortable === true) { $exists = false; foreach ($this->columns as $column) { if (isset($column['class']) && $column['class'] == 'SortableColumn') { $exists = true; } } if ($exists === false) { array_push($this->columns, array('class' => 'SortableColumn')); } } $this->_generateClipboardData(); $this->_removeData(); Yii::app()->clientScript->registerScript("sortable-clipboard", "\n \$('.sortable-clipboard-area').sortable({\n connectWith : '.sortable-items tbody'\n });\n ", CClientScript::POS_READY); parent::initColumns(); }
/** * Redeclare initialization */ public function init() { parent::init(); if ($this->enablePageSizing) { if ($pageSize = Yii::app()->request->getParam($this->id . '-page-size')) { $this->pageSize = $pageSize; Yii::app()->session[$this->id . '-page-size'] = $this->pageSize; } elseif (isset(Yii::app()->session[$this->id . '-page-size'])) { $this->pageSize = Yii::app()->session[$this->id . '-page-size']; } if ($this->dataProvider->getPagination() !== false) { $this->dataProvider->getPagination()->setPageSize($this->pageSize); } else { $this->dataProvider->setPagination(array('class' => 'CPagination', 'pageSize' => $this->pageSize)); $this->enablePagination = true; } $this->dataProvider->getData(true); } }
public function init() { $this->pager = array( 'cssFile' => false, 'header' => false, 'htmlOptions' => array('class' => 'pagination'), 'prevPageLabel' => '«', 'previousPageCssClass' => 'arrow', 'nextPageLabel' => '»', 'nextPageCssClass' => 'arrow', 'firstPageLabel' => false, 'firstPageCssClass' => 'hide', 'lastPageLabel' => false, 'lastPageCssClass' => 'hide', 'selectedPageCssClass' => 'current', ); parent::init(); }
public function registerClientScript() { if (!Yii::app()->request->isAjaxRequest) { parent::registerClientScript(); $cs = Yii::app()->clientScript; $basePath = Yii::getPathOfAlias('ext.NPager.assets'); $baseUrl = Yii::app()->getAssetManager()->publish($basePath); $id = parent::getId(); $cs = Yii::app()->clientScript; $cs->registerCoreScript('jquery'); $js = "function {$id}" . "_changePageSize(id,url)\n"; $js .= "{\n"; $js .= " url = {url:url+\$('#'+id+'>.{$this->pagerlistCssClass}>select').val()};\n"; $js .= " \$.fn.yiiGridView.update(id,url);\n"; $js .= "}\n"; $js .= "\n"; $cs->registerScript($this->getId(), $js, CClientScript::POS_END); $cs->registerCssFile($baseUrl . '/style.css'); } }
public function registerClientScript() { // attach ajax events $updateParameters = array(); if (isset($this->ajaxUpdateError)) { $updateParameters['ajaxUpdateError'] = (strpos($this->ajaxUpdateError, 'js:') !== 0 ? 'js:' : '') . $this->ajaxUpdateError; } if (isset($this->afterAjaxUpdate)) { $updateParameters['afterAjaxUpdate'] = (strpos($this->afterAjaxUpdate, 'js:') !== 0 ? 'js:' : '') . $this->afterAjaxUpdate; } if (isset($this->beforeAjaxUpdate)) { $updateParameters['beforeAjaxUpdate'] = (strpos($this->beforeAjaxUpdate, 'js:') !== 0 ? 'js:' : '') . $this->beforeAjaxUpdate; } parent::registerClientScript(); $id = $this->getId(); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile(Yii::app()->getAssetManager()->publish(__DIR__ . '/assets') . '/js/jquery.yiilivegridview.js'); $cs->registerScript(__CLASS__ . '# ' . $id, "jQuery('#{$id}').yiiLiveGridView();"); $cs->registerScript(__CLASS__ . '# ' . $id . '-live', "setInterval(function(){;\$.fn.yiiLiveGridView.update( '{$id}', " . CJavaScript::encode($updateParameters) . ");}, {$this->updatingTime});"); }
/** * Renders the summary-clone changer. When the summary changes, it should update the summary-clone in the * searchview if it is available. The ModalListView does not rely on this because it does not run * jquery.globalEval on ajax changes such as pagination. It instead will call processListViewSummaryClone which * is decleared @see ModalListView->getCGridViewAfterAjaxUpdate() * */ public function renderSummary() { parent::renderSummary(); Yii::app()->clientScript->registerScript($this->id . '_listViewSummaryChangeScript', ' processListViewSummaryClone("' . $this->id . '", "' . $this->summaryCssClass . '", "' . $this->summaryCloneId . '"); '); }
public function run() { if ($this->grid_mode == 'export') { $this->renderHeader(); $row = $this->renderBody(); $this->renderFooter($row); //set auto width if ($this->autoWidth) { foreach ($this->columns as $n => $column) { $this->objPHPExcel->getActiveSheet()->getColumnDimension($this->columnName($n + 1))->setAutoSize(true); } } //create writer for saving $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->exportType); if (!$this->stream) { $objWriter->save($this->filename); } else { if (!$this->filename) { $this->filename = $this->title; } $this->cleanOutput(); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-type: ' . $this->mimeTypes[$this->exportType]['Content-type']); header('Content-Disposition: attachment; filename="' . $this->filename . '.' . $this->mimeTypes[$this->exportType]['extension'] . '"'); header('Cache-Control: max-age=0'); $objWriter->save('php://output'); Yii::app()->end(); } } else { parent::run(); } }
/** *### .initColumns() * * Creates column objects and initializes them. */ protected function initColumns() { foreach ($this->columns as $i => $column) { if (is_array($column) && !isset($column['class'])) { $this->columns[$i]['class'] = 'bootstrap.widgets.TbDataColumn'; } } parent::initColumns(); if ($this->responsiveTable) { $this->writeResponsiveCss(); } }
public function run() { if ($this->grid_mode == 'export') { if ($this->company) { self::$activeSheet->setCellValue('A' . (string) ($this->offset - 2), $this->company, true); } if ($this->rate_line) { self::$activeSheet->setCellValue('A' . (string) ($this->offset - 1), $this->rate_line, true); } $this->renderHeader(); $row = $this->renderBody(); $this->renderFooter($row); //set auto width if ($this->autoWidth) { foreach ($this->columns as $n => $column) { $cell = self::$activeSheet->getColumnDimension($this->columnName($n + 1))->setAutoSize(true); } } // Set some additional properties self::$activeSheet->setTitle($this->sheetTitle)->getSheetView()->setZoomScale($this->zoomScale); self::$activeSheet->getHeaderFooter()->setOddHeader('&C' . $this->sheetTitle)->setOddFooter('&L&B' . self::$objPHPExcel->getProperties()->getTitle() . $this->pageFooterText); self::$activeSheet->getPageSetup()->setPrintArea('A1:' . $this->columnName(count($this->columns)) . ($this->offset + $row + 2))->setFitToWidth(); //create writer for saving $objWriter = PHPExcel_IOFactory::createWriter(self::$objPHPExcel, $this->exportType); if (!$this->stream) { $objWriter->save($this->filename); } else { //output to browser if (!$this->filename) { $this->filename = $this->title; } $this->cleanOutput(); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-type: ' . $this->mimeTypes[$this->exportType]['Content-type']); header('Content-Disposition: attachment; filename="' . $this->filename . '.' . $this->mimeTypes[$this->exportType]['extension'] . '"'); header('Cache-Control: max-age=0'); $objWriter->save('php://output'); Yii::app()->end(); } } else { parent::run(); } }
public function run() { if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->runAjax(); } else { parent::run(); } }
public function renderSummary() { if (AuxLib::getLayoutType() === 'responsive' && $this->enableResponsiveTitleBar) { Yii::app()->clientScript->registerCss('mobileDropdownCss', "\n .grid-view .mobile-dropdown-button {\n float: right;\n display: block;\n margin-top: -24px;\n margin-right: 8px;\n }\n "); $afterUpdateJSString = "\n ;(function () {\n var grid = \$('#" . $this->id . "');\n \$('#" . $this->namespacePrefix . "-mobile-dropdown').unbind ('click.mobileDropdownScript')\n .bind ('click.mobileDropdownScript', function () {\n if (grid.hasClass ('show-top-buttons')) {\n grid.find ('.page-title').css ({ height: '' });\n grid.removeClass ('show-top-buttons');\n } else {\n grid.find ('.page-title').animate ({ height: '68px' }, 300);\n grid.addClass ('show-top-buttons');\n \$(window).one ('resize', function () {\n grid.find ('.page-title').css ({ height: '' });\n grid.removeClass ('show-top-buttons');\n });\n }\n });\n }) ();\n "; $this->addToAfterAjaxUpdate($afterUpdateJSString); echo '<div id="' . $this->namespacePrefix . '-mobile-dropdown" class="mobile-dropdown-button"> <div class="x2-bar"></div> <div class="x2-bar"></div> <div class="x2-bar"></div> </div>'; } parent::renderSummary(); }
public function init() { parent::init(); $this->initColumns(); }
public function registerClientScript() { parent::registerClientScript(); if ($this->enableGvSettings) { Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/colResizable-1.2.x2.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/jquery.dragtable.x2.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/x2gridview.js'); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId() . '_gvSettings', "\$('#" . $this->getId() . " table').gvSettings({\n\t\t\t\tviewName:'" . $this->viewName . "',\n\t\t\t\tcolumnSelectorId:'" . $this->columnSelectorId . "',\n\t\t\t\tcolumnSelectorHtml:'" . addcslashes($this->columnSelectorHtml, "'") . "'\n\t\t\t});", CClientScript::POS_READY); } }