Updating Cgridview With Yiigridview('update')

Hi guys, just a quick question: why does this button successfully refresh my grid

<button id="refresh-button">Aggiorna</button>

<?php Yii::app()->clientScript->registerScript('initRefresh',"

    $('#refresh-button').on('click',function(e) {





,CClientScript::POS_READY); ?>

But adding " $(’#appalto-grid’).yiiGridView(‘update’);" in my following script will have no effect? Here it is:

<script type="text/javascript">  

  <?php echo CHtml::ajax(array(


            'data'=> "js:$(this).serialize()",





                if (data.status == 'failure')


                    $('#dialogAppalto div.divForForm').html(data.div);

                          // Here is the trick: on submit-> once again this function!

                    $('#dialogAppalto div.divForForm form').submit(addAppalto);




                    $('#dialogAppalto div.divForForm').html(data.div);

                    setTimeout(\"$('#dialogAppalto').dialog('close') \",3000);




            } ",


    return false; 





Cheers! :)


This line should be called when in positive response…but u r calling outside the condition. so it wont work…


Check my below code …


						$.fn.yiiGridView.update('module-grid', {



					        success:function(data) {




					    return false;


That Worked :) but why


and not


is the second syntax incorrect or deprecated? Cheers :)

For you information…

check this code


Yii itself uses code like you…


     	* Performs an AJAX-based update of the grid view contents.

     	* @param id string the ID of the grid view container

     	* @param options map the AJAX request options (see jQuery.ajax API manual). By default,

     	* the URL to be requested is the one that generates the current content of the grid view.


        $.fn.yiiGridView.update = function (id, options) {

                $('#' + id).yiiGridView('update', options);




[size=2]i think we need second ajax options… without options there is no update method :)[/size]