本文介绍了从表视图填充网格时如何在CGrideView中设置键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Yii CGridView中,当我们使用以下方法从网格中选择任何一行时:

它给出记录的正确键值网格由表填充)




但是,当我使用3个表格的数据填充Grid时, strong> View 。键值返回undefined。



我有 id 在该特定视图中键值。所以,我可以让特定行的Id继续进行。



ps:

所有3个表都有自己的主键。

解决方案

您是否查看过这些选项?





它们是用于在gridview 中生成该id的内容

In Yii CGridView, when we select any row from grid by using:

it gives proper key value of the record (when the grid is populated by table)


But, when I populate Grid with data of 3 tables as a View. The key value returns undefined.

I have id as field, and I want it as key value in that particular view. So, I can get Id of particular row to proceed further.

p.s.:
All the 3 tables have their own Primary Key.

解决方案

Have you looked into these options?

KeyAttribute (CActiveDataProvider)

KeyField (CArrayDataProvider)

They are what is used to generate that id in a gridview

这篇关于从表视图填充网格时如何在CGrideView中设置键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 15:16