Hello everyone. I’m using a CGridView with a data provider (CArrayDataProvider) and it’s working fine. However, now I’d like to show a couple of additional related columns in the table (CGridView). Due to the complexity of the SQL instruction that populates the data provider initially, I’m afraid I will have to use another SQL instruction to get the data I need for the additional columns.
To make a simple example, let’s say I’m displaying a table with a list of users, and now I’d like to show an additional value for each of them.
Now:
Users
Id | Name | Address
What I’d like to show:
Users
Id | Name | Address | Earnings | Current level
What do you guys think would be the best approach to do this? Please remember that I need to use another SQL instruction, in other words, I would have a second data provider but, as far as I know, the CGridView would only accept one as a parameter.
I guess this wouldn’t be a problem at all if I were to construct the “html table” by myself using a foreach statement, because on each iteration I could just grab the additional data from the second data provider variable, like this:
foreach row in dataProvider1
dataProvider2 = get data needed using dataProvider1 data as a parameter for the SQL query here. (Example: the earnings for each user)
end foreach
but using the CGridView, I have to specify the fields to show in a "non-foreach" style.
I hope that I could explain myself correctly. I will appreciate any ideas to solve this issue. I will be glad to clarify anything in this post.
Thank you in advance!