Yii Framework Forum: How Refresh Grid - Yii Framework Forum

Jump to content

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

How Refresh Grid refresh gridview

#1 User is offline   iqnev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 25-March 14

Posted 27 March 2014 - 09:34 AM

Hi,
how you refresh gridview with js? I try with this cod
$('#books-heads').yiiGridView('init');
but it's not work!
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,601
  • Joined: 04-March 10
  • Location:UK

Posted 27 March 2014 - 09:38 AM

Try this:
$.fn.yiiGridView.update('books-heads');

0

#3 User is offline   iqnev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 25-March 14

Posted 27 March 2014 - 09:42 AM

View PostKeith, on 27 March 2014 - 09:38 AM, said:

Try this:
$.fn.yiiGridView.update('books-heads');



I try this, but it not work too

Quote

TypeError: Object function (method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { ...<omitted>... } has no method 'update'

0

#4 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,601
  • Joined: 04-March 10
  • Location:UK

Posted 27 March 2014 - 09:43 AM

Ah, I assumed that it was the same as in Yii 1.1.x. I'm not sure of the recommended way to refresh the grid in Yii 2.

EDIT:
Maybe the applyFilter method will do it?
0

#5 User is offline   iqnev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 25-March 14

Posted 27 March 2014 - 04:31 PM

View PostKeith, on 27 March 2014 - 09:43 AM, said:

Ah, I assumed that it was the same as in Yii 1.1.x. I'm not sure of the recommended way to refresh the grid in Yii 2.

EDIT:
Maybe the applyFilter method will do it?

Yes in Yii 2 is different! Any other ideas?
0

#6 User is offline   Nicola 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 210
  • Joined: 13-March 11
  • Location:Italy

Posted 28 March 2014 - 03:19 AM

Use Pjax

Pjax::begin();
echo GridView::widget([...]);
Pjax::end();


Then write your JS code to handle the refresh of the grid.
Yii2 Pjax documentation
My company: DigiSin
0

#7 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 613
  • Joined: 29-August 12

Posted 28 March 2014 - 05:51 AM

As mentioned by Nicola, by enclosing the gridview within Pjax widget, you can automatically refresh the grid. Any link (on click) or form (on submit), enclosed within the Pjax widget will trigger the grid refresh automatically, if you have set its data-pjax property.

Alternatively, you can set the linkSelector and formSelector properties within the Pjax widget.
0

#8 User is offline   iqnev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 25-March 14

Posted 28 March 2014 - 07:50 AM

View PostKartik V, on 28 March 2014 - 05:51 AM, said:

As mentioned by Nicola, by enclosing the gridview within Pjax widget, you can automatically refresh the grid. Any link (on click) or form (on submit), enclosed within the Pjax widget will trigger the grid refresh automatically, if you have set its data-pjax property.

Alternatively, you can set the linkSelector and formSelector properties within the Pjax widget.

example with linkSelector and formSelector ??
0

#9 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 613
  • Joined: 29-August 12

Posted 28 March 2014 - 08:46 AM

View Postiqnev, on 28 March 2014 - 07:50 AM, said:

example with linkSelector and formSelector ??

For example, if you want to target pjax refresh only on the following two things
<a class='my-link'>XYZ</a>
<form id='my-form'></form>

then you can set
'linkSelector' => 'a.my-link'
'formSelector' => '#my-form'

Disclaimer: Not tested or used this (just my understanding of the way it should be).
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