Yii Framework Forum: CGridView + ajax - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CGridView + ajax Rate Topic: -----

#1 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 09 March 2010 - 03:54 AM

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.
0

#2 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 751
  • Joined: 02-February 09

Posted 09 March 2010 - 07:19 AM

View Postbitmatix, on 09 March 2010 - 03:54 AM, said:

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.
0

#3 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 10 March 2010 - 07:14 AM

View Postbettor, on 09 March 2010 - 07:19 AM, said:

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.
0

#4 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 751
  • Joined: 02-February 09

Posted 10 March 2010 - 11:17 AM

you can use ajaxSubmitButton
0

#5 User is offline   Matt Kelliher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 12-February 10
  • Location:Tampa, FL

Posted 10 March 2010 - 11:43 AM

Update content in AJAX with partialRender

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

#6 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 12 March 2010 - 06:38 AM

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.
0

#7 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 12 March 2010 - 08:22 AM

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

#8 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 12 March 2010 - 08:36 AM

View Postqiang, on 12 March 2010 - 08:22 AM, said:

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()
{
$.fn.yiiGridView.update('#yw0');
}
var interval = setInterval("refreshList()", 2000);
</script>
0

#9 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 12 March 2010 - 08:44 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users