Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.1 or above
Installation ¶
Extract both Classes to application/extensions/
CEditableGridView represents a grid view which contains editable rows and an optional 'Quickbar' which fires an action that quickly adds entries to the table.
When you assign an Column an relation-field (for example 'post.author') this Widget automatically renders an Drop-Down Field to choose between the available actions. To achieve this, the Relation-Widget is used (it is contained in the release) (since 0.2)
To make a Column editable you have to assign it to the class 'CEditableColumn'
Use it like the CGridView:
$this->widget('zii.widgets.grid.CEditableGridView', array(
'dataProvider'=>$dataProvider,
'showQuickBar'=>'true',
'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate()
'columns'=>array(
'title', // display the 'title' attribute
array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'CEditableColumn')
));
With this Config, the column "editable_row" gets rendered with inputfields. The Table-header will be called "editMe".
You have to define a action that receives $_POST data like this:
public function actionQuickCreate() {
$model=new Model;
if(isset($_POST['Model']))
{
$model->attributes=$_POST['Model'];
if($model->save())
$this->redirect(array('admin')); //<-- assuming the Grid was used unter view admin/
}
}
Note: When using the newest "filter"-technique of Yii the automatic relation resolvment fails; so be sure to comment out the 'filter' => $model, generated by the yiic crud command.
Still todo ¶
make inputs writeable by JavaScript
make Drop-Down-List filterable by a criteria (will be in 0.3 soon)
Change Log ¶
January 26, 2010 ¶
- The Widget now renders an automatic DropDownList when
- an relation field (for example post.author) occurs
January 19, 2010 ¶
- Initial release.
works for me!!
After I made some adjustments I now can update the editable fields, still need something to delete the model..
Usefull?
I wonder what the use of the editable fields are? They are not posted in the current implementation (v 0.2), only the QuickBar gets posted.
Is there another editable field control ?
Hi..
This is what I'm looking for, good Job. But if I want a different editable field , for examle like dropdown or check box ?
Is there any suggesstion ? or something tutorial /example ?
Thanks a lot
Stefanus
How the QuickCreate Action Work?
Can you explain how the QuickCreate Action Work?
I dont see a submit button there to process the changes/input on editable_row.
looking for code to post the changed rows
hi,
is there any new updates on this, would appreciate the help if could post the code to update the editable rows
great work!!
Thanks
progress/news
unfortunately i do not have a project that needs a "updated" version of the CEditableGridView yet - altough i already have a lot of ideas on what could be made better.
For example, after -ing out of a column it could get green after a successfull ajax request that saved the column, yellow with a validation error message if it fails, and red if another error occurs. As soon as i need this funtionality in one of my projects i definitely will make it modular and release it under this extension.
If you want you could start something like that - any help is appreciated of course ;)
good to know that someone still looks at this extension even if it is >1 year old ;)
can you tell me how to use
hello
getting this error
Alias "zii.widgets.grid.CEditableGridView" is invalid. Make sure it points to an existing PHP file
i extracted file under the extension folder
$this->widget('zii.widgets.grid.CEditableGridView', array(
'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'Source', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'CEditableColumn') ),));
Saving the edited data?
I have seen a few comments on saving the edited data to the database, but don't see an answer. When I hit save on the main record, the value in the updated edited column of the grid does not save..
How do you save the data in the CEditableColumn?
_form
$this->widget('zii.widgets.grid.CEditableGridView', array( 'dataProvider'=>$perfreviewsub->searchbyparent($model->performancereviewid), 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'standardname', 'elementname', array('header' => 'ratingid', 'name' => 'ratingid', 'class' => 'CEditableColumn'), )) );
Controller
public function actionQuickCreate() { $model=new PerfReviewSub; if(isset($_POST['PerfReviewSub'])) { $model->attributes=$_POST['PerfReviewSub']; if($model->save()) $this->redirect(array('update')); //<-- assuming the Grid was used unter view admin/ } }
Reply to #3983
nadeem #3983 ran into the error: Alias "zii.widgets.grid.CEditableGridView" is invalid. This is a documentation problem. The documentation's example was:
$this->widget('zii.widgets.grid.CEditableGridView', array( 'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'title', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'CEditableColumn') ));
If you followed the installation instructions and put the class file in the extensions directory, the this should be:
$this->widget('ext.CEditableGridView', array( 'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'title', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'ext.CEditableColumn') ));
I instead created an editableGrid subdirectory (of the extensions directory) for the class files. This requires changing the example code to:
$this->widget('ext.editableGrid.CEditableGridView', array( 'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'title', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'ext.editableGrid.CEditableColumn') ));
Now I to need to figure out to get it to save the edited cell.
how to reload grid after quickcreate???
hi, how can i reload the gridview after quickcreate. my form have 2 models and i just would like to reload the child grid after create aand the parent still in update form.
thanks.
links are broken
Hi!
I'd like to try the demo, but it seems the links at the top :
> - Home page
> - Try out a demo
> - Join discussion
> - Report a bug
are broken...
Where can I see a demo?
(And maybe fix those links while you're here...)
Cheers!
Update through CEditableGridView
i want to display textbox in and dropdownlist in CEditableGridView , i want to update perticular record dont want to create.
anybody cna help me?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.