Cgridview displaying a gridview in multiple gridviews yii based on some ids
#1
Posted 10 October 2012 - 05:14 AM
We have a table as follows
1 Beckham Soccer
1 Van Persie Soccer
2 Federer Tennis.
Now I want to convert this grid into two grids on the basis of gameids(1 and 2).
The result should be two grids with the first two rows in one grid and the last one in another grid.
#2
Posted 10 October 2012 - 05:36 AM
#3
Posted 10 October 2012 - 05:53 AM
#4
Posted 10 October 2012 - 05:54 AM
This time you will simply create two empty models and then set their gameid.
$model1->gameid = 1;
$model2->gameid = 2;
Then you render your form containing two separate gridviews, and you pass both of these models to the form. Each gridview will use a different model to filter its records.
Check this wiki to see more detail about what I said above:
CGridView, CListView and CActiveDataProvider
Check this wiki to see how to have two gridviews on one form:
Dynamic GridViews
#5
Posted 10 October 2012 - 07:21 AM
waterloomatt, on 10 October 2012 - 05:53 AM, said:
#6
Posted 10 October 2012 - 07:26 AM
First I am doing a search operation using controller and CDbCriteria. Then I get the desired output as elicited in the post.Now My task is to display these individual grids on the same form.So,please show me an example with a generalised one,not a specific one with two grids...
Gerhard Liebenberg, on 10 October 2012 - 05:54 AM, said:
This time you will simply create two empty models and then set their gameid.
$model1->gameid = 1;
$model2->gameid = 2;
Then you render your form containing two separate gridviews, and you pass both of these models to the form. Each gridview will use a different model to filter its records.
Check this wiki to see more detail about what I said above:
CGridView, CListView and CActiveDataProvider
Check this wiki to see how to have two gridviews on one form:
Dynamic GridViews
#7
Posted 10 October 2012 - 08:36 AM
In the controller, you work out how many gridviews you need and create an empty model for each gridview. Then set the filtering parameters on these empty models e.g.
$model1->gameid = 1;
$model2->gameid = 2;
$model3->gameid = 3;
Then pass all these models to a MasterView.
In the MasterView, I would have a section that tests what models were received. For each model received, I would render a subView, which contains the CGridView for that model.
The fastest way to learn Yii is to work out complex stuff like this. Then come back here and tell us how you did it.
#8
Posted 10 October 2012 - 11:08 PM
Gerhard Liebenberg, on 10 October 2012 - 08:36 AM, said:
In the controller, you work out how many gridviews you need and create an empty model for each gridview. Then set the filtering parameters on these empty models e.g.
$model1->gameid = 1;
$model2->gameid = 2;
$model3->gameid = 3;
Then pass all these models to a MasterView.
In the MasterView, I would have a section that tests what models were received. For each model received, I would render a subView, which contains the CGridView for that model.
The fastest way to learn Yii is to work out complex stuff like this. Then come back here and tell us how you did it.
#9
Posted 11 October 2012 - 03:09 AM
But how is your DB structured? Why don't you know beforehand how many gridviews you will need?
#10
Posted 11 October 2012 - 04:40 AM
To me that sounds like the classic parent-child gridview scenario: You have a parent gridview - displaying all the games. If the user clicks on a game, a second gridview is displayed with more details for that specific game only.
This way you only have 2 gridviews - instead of an unknown amount.
Check the "Dynamic GridViews" wiki I mentioned above, which will show you how to do parent-child gridviews.
#11
Posted 11 October 2012 - 07:15 AM
I recently had to display a list of inventories and their respective sales. I rendered the list of inventories in a ListView and each inventory displayed a grid of sales data. Is this what you mean?
many_grid.jpg (166.96K)
Number of downloads: 19
Matt
#12
Posted 12 October 2012 - 01:31 AM
waterloomatt, on 11 October 2012 - 07:15 AM, said:
I recently had to display a list of inventories and their respective sales. I rendered the list of inventories in a ListView and each inventory displayed a grid of sales data. Is this what you mean?
Matt

Help











