CGridView UpdateSelector

Hi,

I’m trying to update a div after an ajax call on a CGridView. Am I calling the updateSelector & ajaxUpdate properties correctly?

After a manual page reload, the correct message is displayed. Is the updateSelector property fired onClick or when the it receives a response from the controller?

Thanks,

Matt




<div id="adminPanel">


    <?php $this->widget('NotificationWidget'); ?>


    <?php

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

        'id' => 'user-grid',

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

        'filter' => $model,

        'ajaxUpdate' => 'adminPanel',

        'updateSelector' => '.emailLink',

        'columns' => array(

            array(

                'type' => 'raw',

                'value' => 'CHtml::ajaxLink(

                    "Send Email Validation",

                    Yii::app()->createUrl("admin/user/email"),

                    array( // ajaxOptions

                        "type" => "POST",

                        "data" => array("id" => $data->id),

                    ),

                    array( //htmlOptions

                        "href" => Yii::app()->createUrl("admin/user/email", array("id" => $data->id)),

                        "class" => "emailLink",

                    )

                )'

            ),

        ),

    )); ?>

</div>



Haven’t figured out how to use the updateSelector on an ajaxLink yet, but here’s a workaround. Notice the success property of the ajaxLink.




<?php

$this->menu = array(

    array('label' => 'List User', 'url' => array('index')),

    array('label' => 'Create User', 'url' => array('create')),

);

?>


<h1>Manage Users</h1>


<div id="adminPanel">


    <?php $this->widget('NotificationWidget'); ?>


    <?php

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

        'id' => 'user-grid',

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

        'filter' => $model,

        'cssFile' => Yii::app()->baseUrl . '/css/gridViewStyle/gridView.css',

        'htmlOptions' => array('class' => 'grid-view rounded'),

        'ajaxUpdate' => 'adminPanel',

        'updateSelector' => '.emailLink',

        'template' => '{items}{pager}',

        'columns' => array(

            array(

                'name' => 'status',

                'value' => 'Lookup::item("UserStatus",$data->status)',

                'filter' => Lookup::items('UserStatus'),

            ),

            array(

                'name' => 'role_id',

                'value' => '$data->role->name',

                'filter' => CHtml::listData(Role::model()->findAll(), 'id', 'name'),

            ),

            'email_address',

            'create_time',

            array(

                'type' => 'raw',

                'value' => 'CHtml::ajaxLink(

                    "Send Email Validation",

                    Yii::app()->createUrl("admin/user/email", array("id" => $data->id)),

                    array( // ajaxOptions

                        "type" => "POST",

                        "data" => array("id" => $data->id),

                        "success" => "function()

                        {

                            $.fn.yiiGridView.update(\'user-grid\');

                        }",

                    ),

                    array( //htmlOptions

                        "href" => Yii::app()->createUrl("admin/user/email", array("id" => $data->id)),

                        "class" => "emailLink",

                    )

                )'

            ),

            array(

                'class' => 'CButtonColumn',

            ),

        ),

    )); ?>

</div>




Matt