CGridView + ajax

How can I update the content of a CGridView with an ajax action? I want to fetch new items from database and add them to the grid with ajax.

are you talking about filtering…sorting…???

please provide what you’ve developed so far and where you got stuck.

I have an application which writes new entry in the database, and after writing I want to refresh the CGridView without loading the page again.

you can use ajaxSubmitButton

Update content in AJAX with partialRender

You should be able to modify this Cookbook entry to get what you need too.

What I want to do is to update CGridView periodically without loading the page every time. I still don’t know how to achive that. I think it must a javascript funciton call with “setInterval”, but I don’t know which function to call with interval.

You need to write js code that can periodically call: $.fn.yiiGridView.update(gridID)

If I do so, I always get an error: $.fn.yiiGridView is not undefinded

I have the following code:

<script type="text/javascript">

function refreshList()




var interval = setInterval("refreshList()", 2000);


Check your HTML source code to make sure jquery.yiigridview.js is included (it should if you use CGridView).