English 中文(简体)
Yi网: 争取获得非目标财产
原标题:Yii bootstrap grid: Trying to get property of non-object

This:

$gridDataProvider = new CArrayDataProvider(array(
    array( id =>1,  firstName => Mark ,  lastName => Otto ,  language => CSS ),
    array( id =>2,  firstName => Jacob ,  lastName => Thornton ,  language => JavaScript ),
    array( id =>3,  firstName => Stu ,  lastName => Dent ,  language => HTML ),
));


 $this->widget( bootstrap.widgets.BootGridView , array(
     type => striped bordered condensed ,
     dataProvider =>$gridDataProvider,
     template =>"{items}",
     columns =>array(
        array( name => id ,  header => # ),
        array( name => firstName ,  header => First name ),
        array( name => lastName ,  header => Last name ),
        array( name => language ,  header => Language ),
        array(
             class => bootstrap.widgets.BootButtonColumn ,
             htmlOptions =>array( style => width: 50px ),
        ),
    ),
));

正在返回:

Trying to get property of non-object

Menu, Buttons(和所有其他东西)进行罚款。

问题回答

This hapens because the example uses CArrayDataProvider to populate the grid. When you get inside BootButton (the class that generates this column) to see what runs through it, you will see that it is trying to get the primaryKey property from dataprovider, but there is no such property, as the data is of array type.

如果你计划使用ton子,你就必须通过一个CActiveDataprovider供你的电网使用。

因此,试图这样做:

$this->widget( bootstrap.widgets.BootGridView , array(
         type => striped bordered condensed ,
         dataProvider =>$model->search(),
         template =>"{items}{pager}",
         filter =>$model,...

如果模仿是一部积极记录,则由贵方控制。

I don t know what is the code you got in this class -- bootstrap.widgets.BootButtonColumn But whatever it is, this is a what is causing the issue. Make sure you have the full action of each button defined, in order to avoid this issue.

我指的是,在纽伦一栏中,每个纽扣吨位——

 $this->grid->controller->createUrl("action_name", array("param_name" => "param_value")) 

这应当解决这个问题。

It s caused by the Button Column missing variables It should be

array(
         class => bootstrap.widgets.BootButtonColumn ,
         htmlOptions =>array( style => width: 50px ),
                             viewButtonUrl =>null,
                             updateButtonUrl =>null,
                             deleteButtonUrl =>null,
    ),

/





相关问题
how to change a model safe attributes in yii

I have a CActiveRecord model, and I need to change safe attributes list in that model. I have defined the safeAttributes method inside my model, like the following : public function safeAttributes() {...

Accessing a module s action rendered output

I m writing an "Account" module which should take care of everything about accounts: registration, login/logout, user administration, password recovery, account activation, etc. So I thought it would ...

yii components: events and behaviors?

i m currently learning the yii framework and have read their documentation. but i still don t understand the components. what are these. they talk about component events and behaviors. could someone ...

Yii: Customize the results of CAutoComplete

I need to make a dropdown list using CAutoComplete. Everything is set and works fine, here is my code of the action: <?php public function actionSuggestCharacter() { if(Yii::app()->...

热门标签