Question

I'm trying to figure out how to let the user add any numbers of tables or CGridview on a single page. So right now the page has two gridviews in it which will stay fixed. Now i want to add an add button somwhere, clicking on which will give the user another gridview, and so on.

How should i proceed with this. I mean is there an easy way to do this, without resorting to writing everything from scratch.

What i was thinking was to create a new view file using file_put_contents() or fwrite() dynamically everytime the user wants another table on the page? Now following in my line of thinking from where would i create these dynamically view files.

Should i write the whole code of the view and put it in a string, in the controller, and call file_put_contents() from there.

This would cause another problem as the filter needs a specific ajaxUpdate url like this

'ajaxUrl' => Yii::app()->createUrl('project/AjaxUpdate'), 

.

Which would entail i would have also have to dynamically create the actionCode in the project controller for the filter in that dynamic grid to work. eg. project/AjaxUpdateDynamic1, project/AjaxUpdateDynamic2, etc.

So i'm kinda stuck with this problem. I would really appreciate if someone points me in the right direction.

Thanks, in advance,

Maxx

Was it helpful?

Solution

if you had an action for ajax loading your gridviews, you can then set your ajax url to that url and you'd have filtering possible for your model, you can even put multiple gridviews for multiple data providers that can be loaded via a parameter that you have sent along with click of your button and an input.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top