Related Model In Cgridview

Need help on showing a related model in cgridview.

im doing this




        echo $this->renderPartial("//tabuleiro/admin", array("model" => $model->tabuleiro));

then how to use it with cgridview?


var_dump($model->tabuleiro);

$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'tabuleiro-grid',

    'dataProvider' => $model->search(),

    'filter' => $model,

    'columns' => array(

        //  'id',

        'descricao',

        'num_alveolos',

        'cubicagem',

        'comprimento',

        'largura',

        /*

          'active',

          'created_at',

          'updated_at',

         */

        array(

            'class' => 'CButtonColumn',

        ),

    ),

));

If it’s defined in your model’s relations, you can just do this:




$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'tabuleiro-grid',

    'dataProvider' => $model->search(),

    'filter' => $model,

    'columns' => array(

        'relatedModel.relatedModelAttribute' // or tabuleiro.anAttribute

        array(

            'class' => 'CButtonColumn',

        ),

    ),

));



Is that what you mean?

record is there cuase i can see it with cvardumper but cgridview dont show it


CVarDumper::dump($model->tabuleiro[0]);

$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'tabuleiro-grid',

    'dataProvider' => $model->search(),

    //'filter' => $model,

    'columns' => array(

        'tabuleiro.id',

        'tabuleiro.descricao',

        'tabuleiro.num_alveolos',

//        'cubicagem',

//        'comprimento',

//        'largura',

//        'active',

//        'created_at',

//        'updated_at',

        array(

            'class' => 'CButtonColumn',

        ),

    ),

));

Why not pass the whole model?




        echo $this->renderPartial("//tabuleiro/admin", array("model" => $model));

yes all model is there, what happens is that i can see related model with var dump but doesnt show up in cgridview , strange.

code


CVarDumper::dump($model->tabuleiro);

$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'tabuleiro-grid',

    'dataProvider' => $model->search(),

    //'filter' => $model,

    'columns' => array(

        'tabuleiro.id',

        'tabuleiro.descricao',

        'tabuleiro.num_alveolos',

//        'cubicagem',

//        'comprimento',

//        'largura',

//        'active',

//        'created_at',

//        'updated_at',

        array(

            'class' => 'CButtonColumn',

        ),

    ),

));

?>

fixed http://stackoverflow.com/questions/9117099/showing-attributes-of-another-model-in-cgridview