Cgridview

Customise grid view in yii2

大憨熊 提交于 2019-12-03 09:10:51
问题 How to remove summary and sorter for a particular grid view in Yii2. In Yii1.1 we can do that by setting the template property. In yii2 how to achieve this? 回答1: To change only summary option, you can use: 'summary' => "{begin} - {end} {count} {totalCount} {page} {pageCount}", Then, if you want to empty summary set with empty string value like: 'summary'=> "", and to change layouts you can use: 'layout'=> "{summary}\n{items}\n{pager}" Then, if you want to empty layouts set layout with empty

Customise grid view in yii2

不羁岁月 提交于 2019-12-02 22:01:15
How to remove summary and sorter for a particular grid view in Yii2. In Yii1.1 we can do that by setting the template property. In yii2 how to achieve this? To change only summary option, you can use: 'summary' => "{begin} - {end} {count} {totalCount} {page} {pageCount}", Then, if you want to empty summary set with empty string value like: 'summary'=> "", and to change layouts you can use: 'layout'=> "{summary}\n{items}\n{pager}" Then, if you want to empty layouts set layout with empty string value like: 'layout'=> "", Ref link Ref link So, for sample, i think bellow sample code can be help

CGridView Filter duplicate Ajax requests when using Tabs

前提是你 提交于 2019-12-02 15:56:08
问题 In my web application I use tabs and load part of the views per Ajax. So it's possible, that I do load the same CGridView multiple times without reloading the page. If that occurs I become duplicate Ajax requests if I use CGridView Filters. The filters and requests are standard. Following images show those simple filter and 10 GET requests if type the search value once. Here is the code of Tabs-widget I use: $this->widget('bootstrap.widgets.TbTabs', array( 'id' => 'thirdPartyCatTabs', 'title'

CGridView Filter duplicate Ajax requests when using Tabs

久未见 提交于 2019-12-02 11:33:45
In my web application I use tabs and load part of the views per Ajax. So it's possible, that I do load the same CGridView multiple times without reloading the page. If that occurs I become duplicate Ajax requests if I use CGridView Filters. The filters and requests are standard. Following images show those simple filter and 10 GET requests if type the search value once. Here is the code of Tabs-widget I use: $this->widget('bootstrap.widgets.TbTabs', array( 'id' => 'thirdPartyCatTabs', 'title' => Translate::t('project', 'Categories'), 'type' => 'tabs', 'placement' => 'top', 'events' => array(

yii cgridview 动态生成列

寵の児 提交于 2019-12-01 13:29:19
首先用过Yii 的朋友们都知道,yii里面的CActiveDataProvider搭配CGridview真的是太方便了。 但是有一个问题,我们必须在相应的view里面编写好CGridview里面的$columns属性。那么就会固定了$columns的列数。有时候,要显示的内容,是根据数据库查询的信息确定的。很可能会出现列的个数是动态的。 问题描述: 下面是小龙本人遇到的例子: 此例子是一个程序在线评测系统类似,著名的杭电oj和poj 当对每次比赛后学生的成绩进行统计时,会遇到上述问题,在CGridview的$columns除了Rank(排名),team(队伍),Solved(解决的问题),Penalty(罚时)这些必须的列 外,还有比赛的每个题目提交情况需要统计并展示出来。如下图: 但是每个比赛的题目数不是固定的,所以在显示的时候,就要想着如何构造动态的$columns? 解决方案: 首先观察$columns是一个数组。 141301408.png 所以把构造$columns这个数组放在了相应的Controllers的函数里面: 当构造好以后,对view渲染的时候,当作一个参数传递过去。 在相应的view里面使用如下方式编写。 如此就可以把动态列的问题解决掉了。 总结: 其实,本方法的主要思想就是,构造$colmuns放在对应controllers的相应Action函数里面实现。