php - Yii CGridView - Custom Columns -


been looking solution add feature "custom columns"... meaning, present list of columns can show user , selects ones wants see , after selection table updated , add/removes needed columns.

didn't find on google (perhaps has different name looking for...)

anyone has idea on how can accomplished?

thanks in advance!

this not complete sample, can give clues on how implement it. you've define kind of form collect data how grid has rendered. recommend create cformmodel class if there more 3 input fields. create view file form , div or renderpartial of file containing grid:

$form = $this->beginwidget('cactiveformext'); echo $form->errorsummary($model); echo $form->labelex($model,'column1'); echo $form->dropdownlist($model echo $form->error($model,'column1'); echo chtml::ajaxsubmitbutton('updategrid',array('controller/grid'),                                 array('update'=>'#grid'), $this->endwidget(); // can render 'default options' before ajax update $this->renderpartial('_grid',array($customcolumns=>array('id','name'),'dataprovider'=>$dataprovider)); 

in _grid.php view file:

$this->widget('zii.widgets.grid.cgridview', array(     'id' => 'grid',     'dataprovider'=>$dataprovider,     'columns' => $customcolumns; )); 

in controller:

function actiongrid(){     // recover form data, , build custom columns array     $customcolumns = array();     $customcolumns[] = '.....';      $dataprovider = ...;      $this->renderpartial('_formtrabajo', array('customcolumns' => $idsiniestro, 'dataprovider' => $dataprovider'), false); } 

when click ajaxsubmitbutton, form sent url specified through ajax, , reply controller must contain renderpartial of view containing grid, jquery call can replace html correctly. must pass array controller partial view of grid, custom list of columns want display.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -