Property "cgridview.ajaxupdate" Is Not Defined.

Hi,

I am trying to get Dynamic parent and child CGridView on single view working. I have tried to follow this article:

http://www.yiiframework.com/wiki/323/dynamic-parent-and-child-cgridview-on-single-view-using-ajax-to-update-child-gridview-via-controller-after-row-in-parent-gridview-was-clicked/

but I have failed as I get the above error.

Now I am an experienced programmer but am learning PHP, java and the yii framework all on the fly. So I may be attempting too much but hey I like a good challenge.

The difference for me is also that my tables are a one to many relationship.

So I have a Section with many breeds.

This is my models:

rabbitsection

public function rules()


{


	// NOTE: you should only define rules for those attributes that


	// will receive user inputs.


	return array(


		array('RabbitSectionName, RabbitSectionOrder', 'required'),


		array('RabbitSectionOrder', 'numerical', 'integerOnly'=>true),


		array('RabbitSectionName', 'length', 'max'=>100),


		// The following rule is used by search().


		// Please remove those attributes that should not be searched.


		array('RabbitSectionId, RabbitSectionName, RabbitSectionOrder', 'safe', 'on'=>'search'),


	);


}

rabbitbreed

public function rules()


{


	// NOTE: you should only define rules for those attributes that


	// will receive user inputs.


	return array(


		array('RabbitBreedName, RabbitBreedOrder, RabbitSectionId', 'required'),


		array('RabbitBreedOrder, RabbitSectionId', 'numerical', 'integerOnly'=>true),


		array('RabbitBreedName', 'length', 'max'=>100),


		// The following rule is used by search().


		// Please remove those attributes that should not be searched.


		array('RabbitBreedId, RabbitBreedName, RabbitBreedOrder, RabbitSectionId', 'safe', 'on'=>'search'),


	);


}

admin.php

<?php echo CHtml::link(‘Advanced Search’,’#’,array(‘class’=>‘search-button’)); ?>

<div class="search-form" style="display:none">

<?php $this->renderPartial(’_search’,array(

'model'=&gt;&#036;rabbitsection_model,

)); ?>

</div><!-- search-form -->

<div id="sectionView">

/*

&lt;?php &#036;this-&gt;widget('zii.widgets.grid.CGridView', array(


'id'=&gt;'rabbitsection-grid',


'dataProvider'=&gt;&#036;rabbitsection_model-&gt;search(),


'filter'=&gt;&#036;rabbitsection_model,


'columns'=&gt;array(


	'RabbitSectionId',


	'RabbitSectionName',


	'RabbitSectionOrder',


	array(


		'class'=&gt;'CButtonColumn',


	),


),

)); ?>

*/

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'rabbitsection-grid',


'dataProvider'=&gt;&#036;rabbitsection_model-&gt;search(),


'filter'=&gt;&#036;rabbitsection_model,


'columns'=&gt;array(


	'RabbitSectionId',


	'RabbitSectionName',


	'RabbitSectionOrder',


	array(


		'class'=&gt;'CButtonColumn',


	),


),


'ajaxupdate' =&gt; 'rabbitbreed-grid',

)); ?>

</div>

<!-- The childView <div>, renders the _child form, which contains the Child Gridview.

The ajax response will replace/update the whole <div> and not just the gridview. -->

<div id="rabbitbreedView">

&lt;?php


    &#036;this-&gt;renderPartial('_rabbitbreed', array(


    'rabbitbreed_model' =&gt; &#036;rabbitbreed_model, 


    'rabbitsectionID' =&gt; &#036;rabbitsectionID, 


    ))


?&gt;

</div>

<?php

/*Load the javascript file that contains our own ajax function*/


&#036;path = Yii::app()-&gt;baseUrl.'/js/customFunctions.js';


Yii::app()-&gt;clientScript-&gt;registerScriptFile(&#036;path,


CClientScript::POS_END);

?>

_rabbitbreed.php (in view folder of rabbitsection)

<?php

&#036;this-&gt;widget('zii.widgets.grid.CGridView', array(


'id'=&gt;'rabbitbreed-grid',


'dataProvider'=&gt;&#036;rabbitbreed_model-&gt;searchIncludingPermissions(&#036;rabbitsectionID),


'filter'=&gt;&#036;rabbitbreed_model,


'columns'=&gt;array(


    'rabbitbreeedid',


    array(


        'name'=&gt;'RabbitSectionName',


        'value'=&gt;'RabbitSectionName', /* Test for


            empty related fields not to crash the program */


        'header'=&gt;'Breed',


        'filter' =&gt; CHtml::activeTextField(&#036;rabbitbreed_model,


        'rabbitsectionName'),


    ),


    array(


        'class'=&gt;'CButtonColumn',


        'template'=&gt;'{view}{update}{delete}',


        'viewButtonUrl' =&gt; 'array(&quot;rabbitbreed/view&quot;,


        &quot;id&quot;=&gt;&#036;data-&gt;rabbitbreedid)',


        'updateButtonUrl' =&gt; 'array(&quot;rabbitbreed/update&quot;,


        &quot;id&quot;=&gt;&#036;data-&gt;rabbitbreedid)',


        'deleteButtonUrl' =&gt; 'array(&quot;rabbitbreed/delete&quot;,


        &quot;id&quot;=&gt;&#036;data-&gt;rabbitbreedid)',


    ),


),

));

?>

RabbitsectionController.php

public function actionAdmin()


{


        &#036;rabbitsection_model = new Rabbitsection('search');


        &#036;rabbitsection_model-&gt;unsetAttributes();


        


        if (isset(&#036;_GET['Rabbitsection']))


            &#036;rabbitsection_model-&gt;attributes=&#036;_GET['Rabbitsection'];


        


        if(&#33;isset(&#036;_GET['RabbitSectionId'])){


            &#036;group=&quot;A&quot;;


            &#036;criteria=new CDbCriteria;


            &#036;criteria-&gt;compare('RabbitSectionId',&#036;rabbitsection_model-&gt;RabbitSectionId,TRUE);


            &#036;criteria-&gt;compare('rabbitsectionName', &#036;rabbitsection_model-&gt;RabbitSectionName,TRUE);


            &#036;dataProvider = new CActiveDataProvider('rabbitsection', array(


                'criteria'=&gt;&#036;criteria,


            ));


            


            If (count(&#036;dataProvider-&gt;getData())&gt;0){


                &#036;first_model =&#036;dataProvider-&gt;getData();


                &#036;rabbitsectionid = &#036;first_model[0]-&gt;RabbitSectionId;


            }


            else{


                &#036;rabbitsectionid = 0;


            }


        }


        else{


            &#036;group = &quot;B&quot;;


            &#036;rabbitsectionid = &#036;_GET['RabbitSectionId'];


        }


        &#036;rabbitbreed_model = new Rabbitbreed(&quot;searchIncludingBreeds(&#036;rabbitsectionid&quot;);


        &#036;rabbitbreed_model-&gt;unsetAttributes();


        &#036;rabbitbreed_model-&gt;scenario = 'searchIncludingBreeds';


        if(isset(&#036;_GET[&quot;Rabbitsection&quot;]))


            &#036;rabbitbreed_model-&gt;attributes=&#036;_GET[&quot;Rabbitsection&quot;];


        


        if (&#036;group==&quot;A&quot;){


            &#036;this-&gt;render('admin', array(


                'rabbitsection_model'=&gt;&#036;rabbitsection_model,


                'rabbitbreed_model'=&gt;&#036;rabbitbreed_model,


                'RabbitSectionId'=&gt;&#036;rabbitsectionid,


            ));


        }


        else{


            &#036;this-&gt;renderPartial('_rabbitbreed', array(


            'rabbitbreed_model'=&gt;&#036;rabbitbreed_model,


            'RabbitSectionId' =&gt; &#036;rabbitsectionid,


            ));


            }


}

And I have put the ajax code into a customFunctions.js in a js subfolder.

Now this is where I think I have gone wrong and which is not clear in the article. How do I define the js code in the customFunctions.js?

Or do I have it totally wrong?

Hiya.

I have only ever used Ajax update on a CGridView with the parameter


true

But a possible mistake is it should be


'ajaxUpdate' => 'rabbitbreed-grid',

not


'ajaxupdate' => 'rabbitbreed-grid',

Capital "U"

Could you explain a bit more of what you are trying to achieve.

Regards

Liam

Hi Liam,

Thanks for that. That was the problem…Should have looked at my version of the code closer.

However, I have only moved slightly further forward.

I am having trouble converting the code but I am getting there slowly, I think.

What I am trying to achieve is to have two grids that are linked (actually eventually I want four).The first grid has a list of sections with the second grid having breeds. When a Section is highlighted I want the second grid to have the breeds linked to that section. I was trying to base it around the article mentioned above but it was a many to many and I am using a one to many relationship.