We sometimes want to add elements (lines) when being in "admin view", without changing the page we are on.
Requirements ¶
Yii 1.1
Changelog ¶
- 10/14/2013 : Added the fillIsFilter option. When setted, the fillable row is also filtering the grid.
Installation ¶
- Download the extension and extract the file in your protected/extensions/ directory
- Check that "application.extensions.*" is in your import array in your config file
- Follow the example code (Usage section)
Usage ¶
This extension add a "fillable" section in a CGridView widget. Here is an example of the usage.
The grid contains 4 columns: ColId (id), MyCol1 (text), MyCol2 (text), MyCol3 (relationnal select). We want to add, at the end of the grid, a form with inputs for the fillable fields (not the id) and in the action column a "plus" icon to do the action.
$this->widget('application.extensions.EFillableCGridView', array(
'id'=>'my-grid',
'dataProvider'=>$model->search(),
// **** Here starts the addition ****
'fillable' => array(
'columns' => array(
array(
'name' => 'MyCol1',
'value' => CHtml::textField($model,'MyCol1')
),
array(
'name' => 'MyCol2',
'value' => CHtml::textField($model,'MyCol2')
),
array(
'name' => 'MyCol3',
'value' => CHtml::dropDownList($model, 'MyCol3', CHtml::listData(Col3::model()->findAll(), 'idCol3', 'nameCol3')),
),
),
'CButtonColumn' => array(
'button' => '<a href="'.Yii::app()->createUrl('control/createAjax').'"><img style="vertical-align: middle;" src="'. Yii::app()->baseUrl .'/images/ico_plus.gif" alt="plus"></a>',
'action' => Yii::app()->createUrl('control/createAjax'),
),
'position' => 'bottom',
'fillIsFilter' => true,
),
// **** Here ends the addition ****
'columns'=>array(
'ColId',
'MyCol1',
'MyCol2',
array(
'name' => 'MyCol3',
'value' => '$data->Col3->nameCol3',
),
array(
'class'=>'CButtonColumn',
),
),
));
Explanations ¶
The fillable section contains 4 subsections:
columns is the list of columns you want to add. Each column is defined with a name (must reflect the names used in the grid) and a value: the html input.
CButtonColumn is an array containing action (the action of the ajax form) and button, the html link you'll use to send the form.
position (optional) is where you want to have the form. Default is 'bottom' (after the last line, before footer), you can set it to 'top' (after the filters)
fillIsFilter (optional) allow the fillable row to also be a filter row. When setted to true (or 1, or anything you want), it is a filter until you submit the datas
Error
Hi,
I got this error:
Non-static method CActiveForm::textField() should not be called statically, assuming $this from incompatible context
Any help?
My example is not strict :)
Hello Daniel,
Sorry for this small error, I'll try to do better code next time and verify it.
I didn't got this error because of my permissives settings of PHP.
You're lucky, using the good call, it will work. Replace all the CActiveForm:: with CHtml::
Regards
P.S.: example code corrected
still not working.....
HI,
I am still getting error after changing the CActiveForm to CHtml. The error message is
Object of class ReportSetting could not be converted to string
Thanks,
Daniel
Bug in your relation ?
Hello Daniel,
I think the trouble is not coming from the extension but from the way you use your ReportSetting in it.
Can you join the support thread and show me your view code ?
Installation Please
Can you please let me know the instructions how to install this extnesion
I am getting this error
Property "CGridView.fillable" is not defined.
thank you - reddy
Installation
Hello poorroop,
I've added an "Installation" section in the documentation, check the points 1 & 2 are ok.
And also check you call the good widget (application.extensions.EFillableCGridView).
Regards
Demo ?
Thanks for such valuable work, I really appreciate this as most clients demand for SPA(Single page application) but can give a link for demo to check it immediately rather to test locally and report bugs or say thanks?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.