开发者

How can I use JQuery to change a CListViews dataProvider?

I have th开发者_运维百科e following code, and when a button is clicked i would like to change the dataProvider... how can i do this with JQuery?

$this->widget('zii.widgets.CListView', array(
            'dataProvider'=>$inboxMessages,
            'template'=>"{items}\n{pager}", 
            'itemView'=>'_messageView',
            'id'=>'listMessages',
        ));


You should be able to use the yiiListView.update js helper function to do what you want. You would just need to put a conditional before you create the widget to determine the data provider, e.g.:

$dp = ($_GET['type'] == 'sent') ? $sentMessages : $inboxMessages;
$this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dp,
    ...

Then create a button with a click event like:

$.fn.yiiListView.update('listMessages',
{data:'type=sent', url:'/messages?sort=timestamp&ajax=listMessages'});

You can look here for more info or search for yiilistview.js examples.


I'd wish to think it is possible. However, the data provider is assigned (and processed) in server-side. If you want to change the data provider using jquery, it looks like you'll need to load all the CListView again asynchronously

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜