本文整理汇总了PHP中CGridView::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CGridView::init方法的具体用法?PHP CGridView::init怎么用?PHP CGridView::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGridView
的用法示例。
在下文中一共展示了CGridView::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 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);
}
}
示例2: init
/**
*### .init()
*
* Initializes the widget.
*/
public function init()
{
parent::init();
$classes = array('table');
if (isset($this->type)) {
if (is_string($this->type)) {
$this->type = explode(' ', $this->type);
}
if (!empty($this->type)) {
$validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER);
foreach ($this->type as $type) {
if (in_array($type, $validTypes)) {
$classes[] = 'table-' . $type;
}
}
}
}
if (!empty($classes)) {
$classes = implode(' ', $classes);
if (isset($this->itemsCssClass)) {
$this->itemsCssClass .= ' ' . $classes;
} else {
$this->itemsCssClass = $classes;
}
}
}
示例3: init
/**
* Initializes the grid view.
* This method will initialize required property values and instantiate {@link columns} objects.
*/
public function init()
{
/*$this->options['ajax'] = is_null($this->options['ajax']) ? $this->ajaxUrl : $this->options['ajax'];
if (!in_array($this->dataSources, array('html', 'ajax', 'javascript', 'server-side')))
$this->dataSources = 'html';
if ($this->dataSources == 'server-side')
$this->options['serverSide'] = true;
if ($this->dataSources == 'ajax' && is_null($this->options['ajax'])) {
throw new CException('Error! Not specified property "ajax" in the plugin settings.');
}
if (is_string($this->options['ajax']) && $this->ajaxType == 'POST') {
$this->options['ajax'] = array(
'url' => $this->options['ajax'],
'method' => $this->ajaxType
);
if (Yii::app()->request->enableCsrfValidation)
$this->options['ajax']['data'] = is_array($this->options['ajax']['data']) || is_null($this->options['ajax']['data']) ? CMap::mergeArray($this->options['ajax']['data'], array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)) : array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken);
} else if (is_array($this->options['ajax']) && $this->ajaxType == 'POST') {
$this->options['ajax']['method'] = $this->ajaxType;
if (Yii::app()->request->enableCsrfValidation)
$this->options['ajax']['data'] = is_array($this->options['ajax']['data']) || is_null($this->options['ajax']['data']) ? CMap::mergeArray($this->options['ajax']['data'], array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)) : array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken);
}
if ($this->tableHtmlOptions['data-paging']) {
$this->template = str_replace('{pager}', '', $this->template);
$this->options['pageLength'] = $this->dataProvider->pagination->pageSize;
}
if ($this->tableHtmlOptions['data-ordering']) {
$this->enableSorting = false;
}*/
parent::init();
if (is_null($this->cs)) {
$this->cs = Yii::app()->getClientScript();
}
$this->initDatatables();
}
示例4: init
/**
*### .init()
*
* Initializes the widget.
*/
public function init()
{
parent::init();
$classes = array('table');
if (isset($this->type)) {
if (is_string($this->type)) {
$this->type = explode(' ', $this->type);
}
if (!empty($this->type)) {
$validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER);
foreach ($this->type as $type) {
if (in_array($type, $validTypes)) {
$classes[] = 'table-' . $type;
}
}
}
}
if (!empty($classes)) {
$classes = implode(' ', $classes);
if (isset($this->itemsCssClass)) {
$this->itemsCssClass .= ' ' . $classes;
} else {
$this->itemsCssClass = $classes;
}
}
$popover = Yii::app()->bootstrap->popoverSelector;
$tooltip = Yii::app()->bootstrap->tooltipSelector;
$afterAjaxUpdate = "js:function() {\n\t\t\tjQuery('.popover').remove();\n\t\t\tjQuery('{$popover}').popover();\n\t\t\tjQuery('.tooltip').remove();\n\t\t\tjQuery('{$tooltip}').tooltip();\n\t\t}";
if (!isset($this->afterAjaxUpdate)) {
$this->afterAjaxUpdate = $afterAjaxUpdate;
}
}
示例5: init
public function init()
{
if (isset($_GET[$this->grid_mode_var])) {
$this->grid_mode = $_GET[$this->grid_mode_var];
}
if (isset($_GET['exportType'])) {
$this->exportType = $_GET['exportType'];
}
$lib = Yii::getPathOfAlias($this->libPath) . '.php';
if ($this->grid_mode == 'export' and !file_exists($lib)) {
$this->grid_mode = 'grid';
Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
}
if ($this->grid_mode == 'export') {
$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
$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();
}
}
示例6: init
/**
* Initializes the widget.
*/
public function init()
{
$baseScriptUrl = $this->baseScriptUrl;
parent::init();
$classes = array('table');
if (isset($this->type) && !empty($this->type)) {
if (is_string($this->type)) {
$this->type = explode(' ', $this->type);
}
foreach ($this->type as $type) {
$classes[] = 'table-' . $type;
}
}
if (!empty($classes)) {
$classes = implode(' ', $classes);
if (isset($this->itemsCssClass)) {
$this->itemsCssClass .= ' ' . $classes;
} else {
$this->itemsCssClass = $classes;
}
}
if ($baseScriptUrl === null) {
$baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('bootstrap3.widgets.assets')) . '/gridview';
}
if ($this->cssFile === false) {
$this->cssFile = $baseScriptUrl . '/styles.css';
}
Yii::app()->getClientScript()->registerCssFile($this->cssFile);
}
示例7: init
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();
}
示例8: 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();
}
示例9: init
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();
}
示例10: init
/**
* Initializes the tree grid views.
*/
public function init()
{
parent::init();
if($this->baseTreeTableUrl===null)
$this->baseTreeTableUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.QTreeGridView.treeTable'));
if($this->baseJuiUrl===null)
$this->baseJuiUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.QTreeGridView.jui'));
//Calc parent id from nesteD set
if(count($this->dataProvider->data)) {
$left = $this->dataProvider->data[0]->tree->leftAttribute;
$right = $this->dataProvider->data[0]->tree->rightAttribute;
$level = $this->dataProvider->data[0]->tree->levelAttribute;
$stack = array();
$currentLevel = 0;
$previousModel = null;
try {
foreach($this->dataProvider->data as $model) {
if($model->$level==1) { //root with level=2
$model->parentId = 0;
$currentLevel = 1;
} else {
if($model->$level == $currentLevel) {
if(is_null($stack[count($stack)-1])) {
throw new Exception('Tree is corrupted');
}
$model->parentId = $stack[count($stack)-1]->getPrimaryKey();
} elseif($model->$level > $currentLevel) {
if(is_null($previousModel)) {
throw new Exception('Tree is corrupted');
}
$currentLevel = $model->$level;
$model->parentId = $previousModel->getPrimaryKey();
array_push($stack, $previousModel);
} elseif($model->$level < $currentLevel) {
for($i=0;$i<$currentLevel - $model->$level;$i++) {
array_pop($stack);
}
if(is_null($stack[count($stack)-1])) {
throw new Exception('Tree is corrupted');
}
$currentLevel = $model->$level;
$model->parentId = $stack[count($stack)-1]->getPrimaryKey();
}
}
$previousModel = $model;
}
}
catch (Exception $e) {
Yii::app()->user->setFlash('CQTeeGridView', $e->getMessage());
}
}
}
示例11: init
/**
* 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();
}
示例12: init
public function init()
{
$pageSize = $this->determinePageSize();
if (!isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] = 'grid-view myGrid';
}
$this->pager = array('class' => 'MyPager', 'headerGridID' => $this->id, 'pageSize' => $pageSize);
$this->dataProvider->pagination->pageSize = $pageSize;
return parent::init();
}
示例13: init
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();
}
示例14: init
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
$classes = array('table');
if (isset($this->type) && !empty($this->type)) {
if (is_string($this->type)) {
$this->type = explode(' ', $this->type);
}
foreach ($this->type as $type) {
$classes[] = 'table-' . $type;
}
}
$this->itemsCssClass = implode(' ', $classes);
}
示例15: init
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');
}