editablegridview extension to make rows of anCGridView editable

  1. Documentation
  2. Change Log
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.
4 4
17 followers
6 100 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Tags:
Developed by: thyseus
Created on: Jan 19, 2010
Last updated: 14 years ago

Downloads

show all