Set Action In Widget

i have a widget that showing some data

i want to filter these data interacting with user requests

how can i define actions in a widget ?

no idea ?

i want to do this like ‘CGridView’ that can update table of itself

CGridView uses a jQuery plugin for that.

Take a closer look at the file framework/zii/widgets/assets/gridview/jquery.yiigridview.js

/Tommy

in CGridView pagination buttons are generated like ‘http://127.0.0.1/Keramos/index.php/store/index?PublicInformation_page=2

where this link refer to ?

and how is the integration between this url and jquery.yiigridview.js ???

I investigated some Gii-generated code. In the (normally ajax) call you pass the GET param Yourmodel_page=somenumber. The content of GET (in particular the value of "Yourmodel_page") will be assigned to a new model instance and the controller calls render() as usual. The widget will be instantiated in the view. Since the CGridView property dataprovider is assigned the value $model->search(), a new CActiveDataProvider instance will be created and will bring in the requested page. The jQuery plugin is responsible for filtering out the relevant grid data from the complete page returned to the browser.

The key to which page gets selected is this method in the abstract class CDataProvider, which assigns the name of the actual GET parameter (‘Yourmodel_page’) to the property pageVar of CPagination. The GET-parameter is fetched in this method of CPagination, which is called from e.g. CLinkPager.

Edit: I changed my description of how the GET param is fetched.

/Tommy

oh

how can i implement this feature in my widget?

i don’t use CActiveDataProvider in my widget

i want to filter and change my widget contents on changing the dropdownlist that i create in my widget

for example: i have a widget that shows ‘weather temperature’, and i create a DropDownList of CitiesList in my widget, and when dropdown will change, i want to get this value in my widget and update the label,

how can i ? (i’m implementing a widget like this …)

thanks

Your widget seems to have few similarities to CGridView. Instead of replacing all html you can return selected data using ajax dataType ‘json’.

This cookbook article gives an example of how to make the ajax call (dataType ‘html’, in this case updating the inner html of the element named ‘city_id’.

http://www.yiiframework.com/wiki/24

Also see http://api.jquery.com/jQuery.ajax/

/Tommy

thanks tommy

i read it before

but i don’t know how can i generate links like index.php?param1=AAA&param2=BBB (like CGridView)

in these examples (http://www.yiiframework.com/wiki/24) we pass data to an action

but in widget there is no action …

what could i do ?