Grid Column Buttons In Cgridview Loaded With Ajax

Dear All

I have one problem with cgridview. I have to load a cgridview with ajax. The grid loads up fine but when I add a column with button, I get an error. The error I get is as follows:


<h1>CException</h1>

<p>Property “BootButtonColumn.0” is not defined. (D:\projects\yii\1.13\framework\base\CComponent.php:173)</p><pre>#0 D:\projects\yii\1.13\framework\YiiBase.php(220): CComponent->__set(‘0’, false)

#1 D:\projects\yii\1.13\framework\zii\widgets\grid\CGridView.php(363): YiiBase::createComponent(Array, Object(BootGridView))

#2 D:\projects\testEngine\site\protected\extensions\bootstrap\widgets\BootGridView.php(78): CGridView->initColumns()

#3 D:\projects\yii\1.13\framework\zii\widgets\grid\CGridView.php(334): BootGridView->initColumns()

#4 D:\projects\testEngine\site\protected\extensions\bootstrap\widgets\BootGridView.php(51): CGridView->init()

#5 D:\projects\yii\1.13\framework\web\CBaseController.php(147): BootGridView->init()

#6 D:\projects\yii\1.13\framework\web\CBaseController.php(172): CBaseController->createWidget(‘bootstrap.widge…’, Array)

#7 D:\projects\testEngine\site\themes\bootstrap\views\teacherStudents\_linked_students.php(29): CBaseController->widget(‘bootstrap.widge…’, Array)

#8 D:\projects\yii\1.13\framework\web\CBaseController.php(126): require(‘D:\projects\tes…’)

#9 D:\projects\yii\1.13\framework\web\CBaseController.php(95): CBaseController->renderInternal(‘D:\projects\tes…’, Array, true)

#10 D:\projects\yii\1.13\framework\web\CController.php(869): CBaseController->renderFile(‘D:\projects\tes…’, Array, true)

#11 D:\projects\testEngine\site\protected\controllers\TeacherStudentsController.php(292): CController->renderPartial(’_linked_student…’, Array, true)

#12 D:\projects\yii\1.13\framework\web\actions\CInlineAction.php(49): TeacherStudentsController->actionGetStudents()

#13 D:\projects\yii\1.13\framework\web\CController.php(308): CInlineAction->runWithParams(Array)

#14 D:\projects\yii\1.13\framework\web\filters\CFilterChain.php(133): CController->runAction(Object(CInlineAction))

#15 D:\projects\yii\1.13\framework\web\filters\CFilter.php(40): CFilterChain->run()

#16 D:\projects\yii\1.13\framework\web\CController.php(1145): CFilter->filter(Object(CFilterChain))

#17 D:\projects\yii\1.13\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(Object(CFilterChain))

#18 D:\projects\yii\1.13\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))

#19 D:\projects\yii\1.13\framework\web\CController.php(291): CFilterChain->run()

#20 D:\projects\yii\1.13\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)

#21 D:\projects\yii\1.13\framework\web\CWebApplication.php(282): CController->run(‘getStudents’)

#22 D:\projects\yii\1.13\framework\web\CWebApplication.php(141): CWebApplication->runController(‘teacherStudents…’)

#23 D:\projects\yii\1.13\framework\base\CApplication.php(169): CWebApplication->processRequest()

#24 D:\projects\testEngine\site\index.php(13): CApplication->run()

#25 {main}</pre>


I am using bootstrap as the theme. My code for the cgridview (bootgrid) is as follows:


$this->widget(‘bootstrap.widgets.BootGridView’,array(

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


    'type'=&gt;'striped bordered condensed',


    'dataProvider'=&gt;&#036;pStudents,


    //'filter'=&gt;&#036;pRecords,


    'columns'=&gt;array(


        array(


        	'name'=&gt;'', 'header'=&gt;'#', 


        	'value'=&gt;'CHtml::checkBox(&quot;l_id[]&quot;,null,array(&quot;value&quot;=&gt;&#036;data[&quot;id&quot;],&quot;id&quot;=&gt;&quot;lid_&quot;.&#036;data[&quot;id&quot;]))',


        	'type'=&gt;'raw',


            'htmlOptions'=&gt;array('style'=&gt;'width: 30px'),


        ),


        array('name'=&gt;'Fullname', 'value'=&gt;'&#036;data[&quot;fullname&quot;]'),


        array('name'=&gt;'Username', 'value'=&gt;'&#036;data[&quot;username&quot;]'),


        array('name'=&gt;'Email', 'value'=&gt;'&#036;data[&quot;user_email&quot;]'),


        array('name'=&gt;'Test Count', 'value'=&gt;'&#036;data[&quot;testCounts&quot;]&#33;=&quot;&quot;?&#036;data[&quot;testCounts&quot;]:0'),


        array(


        	'class'=&gt;'bootstrap.widgets.BootButtonColumn',


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


        	'buttons'&gt;array(


        		'view'=&gt;array(


            		'url'=&gt;'Yii::app()-&gt;controller-&gt;createUrl(&quot;view&quot;, array(&quot;id&quot;=&gt;&#036;data[&quot;id&quot;]))',


            		'label'=&gt;'View',


        			)


        	)


        ),


    ),


)); 

Can anybody help me find out the solution for this?

Thanks in advance.

Not sure if it’s a typo but you’re missing an equals sign (=) on the 9th line of code from the bottom.





$this->widget('bootstrap.widgets.BootGridView', array(

    'id' => 'students-grid',

    'type' => 'striped bordered condensed',

    'dataProvider' => $pStudents,

    //'filter'=>$pRecords,

    'columns' => array(

        array(

            'name' => '',

            'header' => '#',

            'value' => 'CHtml::checkBox("l_id[]",null,array("value"=>$data["id"],"id"=>"lid_".$data["id"]))',

            'type' => 'raw',

            'htmlOptions' => array('style' => 'width: 30px'),

        ),

        array(

            'name' => 'Fullname',

            'value' => '$data["fullname"]'),

        array(

            'name' => 'Username',

            'value' => '$data["username"]'),

        array(

            'name' => 'Email',

            'value' => '$data["user_email"]'),

        array(

            'name' => 'Test Count',

            'value' => '$data["testCounts"]!=""?$data["testCounts"]:0'),

        array(

            'class' => 'bootstrap.widgets.BootButtonColumn',

            'template' => '{view}',

            'buttons' => array( // HERE

                'view' => array(

                    'url' => 'Yii::app()->controller->createUrl("view", array("id"=>$data["id"]))',

                    'label' => 'View',

                )

            )

        ),

    ),

));

Matt

Thanks for pointing out my problem! It works.