Issue
The situation is like this: when I first load the page, it displays the data which is powered by a yii widget using e.g
$this->widget(blahblabhablha)
Now, inside that widget, there's clickable dropdown menu, whereby when I click any of the options, I fire an ajax call. Then the backend php script will query the data using the module/controller/action url that I used in the url parameter of $.ajax(). Then I echo json_encode() the data that I fetch from db so that the ajax will get a response.
How to update the widget I just mentioned, using the data response of ajax?, because It's a widget that displays rows and also has pagination, how am I suppose to update that widget to display the data from the ajax response?
Solution
When refreshing grid view for example, Yii actually renders the whole page behind the scenes and then extracts part with gridview div and replaces it. If you are using CgridView, it would be enough for you to set 'ajaxUrl' option when configuring the widget. If not you will have to create html from your ajax response and then place it in the appropriate container via js. Another way, and probably better way is for you to create partial view with only your widget content and then to use renderPartial() in your action to refresh it.
Answered By - Jovana
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.