- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个关系表:location 和 location_types。
位置
- location_id
- location_name
- location_type_id
Location_types
- location_type_id
- location_type
我使用 CGridView 小部件创建了一个 View ,一切正常,甚至文件管理器字段也正常工作,除了在 location_type 列中仅显示 location_type_id。
View 中的 CGridView 小部件:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
array('name' => 'location', 'header' => 'Location'),
array(
'name' => 'location_type_id',
'header' => 'Location Type'
),
),
Location_types 模型中的关系部分
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'locationlocationtype_rel' => array(self::BELONGS_TO, 'Locations', 'location_type_id'),
);
}
那么:如何用 location_type 替换 location_type_id?
最佳答案
array(
'name' => 'location_type_id',
'header' => 'Location Type'
'value' => '$data->locationlocationtype_rel->location_type' // use relations property here
),
关于mysql - 带有关系表的 CGridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20317275/
我正在使用 yii-booster(4.0.1) TbGridView(extends CGridView) 并且需要更改 _REQUEST($_POST, $_GET) 中的过滤器变量名称以实现过滤
我的数据库中有 3 个表, 图片如下,我已关注 http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-
在我的项目中,我使用 cgridview 来显示一些信息并使用使用 cgrid View 构建的分页。但现在我正面临分页的可用性问题。也就是说,考虑我有 3 页,分页看起来像 >> . 当我点击第三
我在 Controller 的索引操作中有这些代码: public function actionIndex() { $cid = @$_GET['cid']; $country = Coun
听起来很简单,对吧?我搜索了高低,我不知道如何做到这一点。我有一个 CGridView: $dataProvider = new CArrayDataProvider ($auctions); $th
我希望删除按钮仅在 CGgridView 中的特定条件下处于事件状态CButtonColumn (或制作自定义删除按钮)例如,如果 user=='admin'或 status=='draft' .有任
我想设置一个 CGridView。我希望在一个 View 中显示来自 2 个不同表的数据。数据来自一个名为 student 的表和另一个名为 employee 的表。 员工由学生推荐(reg_no)
默认情况下,删除按钮将自己分配给此功能: jQuery('#main-orders-details-grid a.delete').live('click',function() { if(!
我有两个关系表:location 和 location_types。 位置 - location_id - location_name - location_type_id Locatio
我正在尝试按category_id过滤gridview中的产品记录 我有三张 table ProductMst(product_id,name) CategoryMst(category_id,cat
我有一个CGridView,它在给定模型上调用search(AFAIK)来获取要显示的模型列表。是否可以通过调用 $model->some_method() 的结果对所述 View 的结果进行排序?
问:如何为我的 gridview 创建过滤器? 状态:客户姓名 = first_name。姓氏 这是我的 GridView widget('zii.widgets.grid.CGridView', a
我需要使用自定义文本字段过滤 CGridView。我有自定义数据提供者(CSqlDataProvider),我返回并用它填充表格。表格很好,但对我来说似乎很痛苦的是过滤它。我已经花了几个小时试图解决这
我正在用 Yii (v1.1.12) 编写我的第一个应用程序,学习曲线对我来说有点陡峭,所以我需要一些帮助。 设想以下表格(及其关系): 详细 (n:1) 文档 文档 (n:1) 用户 用户(n:1)
我已将我的 yii CGridview 的一列作为超链接。但是单击它时,它会在同一选项卡中打开链接地址。如何在新标签页中打开链接地址? array( 'header'=>'Name',
有 enableSorting 标志,如果等于 false,则禁用所有网格列的排序。但是我怎么能只针对一个特定的列做到这一点呢? 最佳答案 试试这个 'sortable'=>false, 这是例子,
我有带分页的简单 Yii cgridview 代码。分页工作正常,但在最后一页我遇到了一个问题。 例如,如果我在 DB 表中有 13 条记录,并将分页设置为每页 10 页,那么对于第一页它将显示 “1
我有一个带有 has_many 关联的模型。 假设学生有很多类(class)。 我想使用 CGridView 显示特定学生的所有类(class)。 像这样的东西: $this->widget('zii
在我的项目中,名为 的模型之一类型 与其他模型有多重关系,部分标准低于其类似 $criteria->with = array( 'category',
如您所知,在 CGridView 中有允许过滤数据的文本框。如何向这些文本框添加类,例如: 最佳答案 取自the forum : $this->widget('zii.widgets.grid.CGr
我是一名优秀的程序员,十分优秀!