ajaxSubmitButton and updating CGridView

Hi,

I have one form and after saving it I want the record to be updated in the CGridView below on the same page.

I have accomplished the saving with ajaxSubmitButton on the form, but can’t get the grid updated, it requres manual refresh.

I have this:

$(’.search-form form’).submit(function(){

$.fn.yiiGridView.update('drum-grid');


return false;

});

but I need it as an afterSave event.

How do i update the grid after saving?

i got the same problem. does anyone khow how to solve it. i’m still strugle to find the answer. it because of i’m new to yii.

thanks

never mind it, i find the solution.


 

echo CHtml::ajaxSubmitButton('reset', CHtml::normalizeUrl(array('userLoginadmin/Resetajax')),

                                array(  

                                        'beforeSend'=>'js:function(){'

                                                        .'$("#mydialog").dialog("open");'

                                                .'}',  

                                     

 'success'=>'js:'

            .'function(){'

            .'$.fn.yiiGridView.update("user-loginadmin-grid", {url:"index.php?r=userLoginadmin/admin"});'

            .'$("#mydialog").dialog("close");'

            .'}',

                                        ),

          array('id'=>'resetME', 'name'=>'resetME'));



maybe this can help someone else.

in my ajaxSubmitButton i got 2 url. first url is this


CHtml::ajaxSubmitButton('reset', CHtml::normalizeUrl(array('userLoginadmin/Resetajax')),

the first url use for call my controller.(ex. is actionResetAjax).

and the 2nd url is for load container CGridView with the newest value after ResetAajax is call.


'success'=>'js:'

            .'function(){'

            .'$.fn.yiiGridView.update("user-loginadmin-grid", {url:"index.php?r=userLoginadmin/admin"});'

            .'$("#mydialog").dialog("close");'

            .'}',

hope this can help other.

sorry for my bad english.

if i’m wrong, please correct me

thanks

hy t3ns4i, recently i have the same problem with u, and fortunatelly u already solved it, but i dont understand ur solution as im new in yii, still need a lot of reading, btw can u show the userLoginadmin/Resetajax action code?

and "user-loginadmin-grid" is this an id of the gridview?

and "resetME" what is this meant?

thanks a lot :)