问题描述
想象一下由CListView呈现的新闻项目的简单列表。每个新闻都有一个'insertDate'属性,我可以通过$ data-> insertDate访问。现在,这样的列表看起来像这样呈现: //示例(如何显示列表)
9-18-2012 - 第二周股票下跌
9-18-2012 - 2012年的纪录高温
9-18-2012 - 该州的犯罪情况下降
9-17-2012 - 股票困境令投资者担忧
2012年9月17日 - 尽管增长缓慢,但业务前景乐观
9-16-2012 - 更多人进入大城市
9-16-2012 - 保持领先今年感染流感
我想要做的是在所有物品上方显示单个日期标题在那一天内,显示器看起来更像这样(下面)。有没有办法调整CListView来做到这一点?
//我想要做的例子
== ===== 9/18的消息======
股票在第二周下跌
在2012年的纪录高温
在该州的犯罪率下降
======= 9/17的消息======
股票困境令投资者担忧
尽管增长缓慢,但业务前景乐观
==== === 9/16的新闻======
更多人进入大城市
今年流感保持领先
您可以试试这一个或此。你可以基于上面这两个来创建自定义的gridview,goodluck。
Imagine a plain list of news items rendered by a CListView. Each news item has an 'insertDate' property that I can access via $data->insertDate. Right now, such a list would look like this rendered:
// example (how list is displayed now)
9-18-2012 - Stocks fell for 2nd week
9-18-2012 - Record heat for 2012
9-18-2012 - Crime down in the state
9-17-2012 - Stock woes are worrying investors
9-17-2012 - Business outlook is optimistic despite slow growth
9-16-2012 - More people moving into big cities
9-16-2012 - Stay ahead of the flu this year
What I want to do is display a single date header above all items that fall within that day so that the display would look more like this (below). Is there a way to tweak CListView to do this?
// example of what i want to do
=======News for 9/18======
Stocks fell for 2nd week
Record heat for 2012
Crime down in the state
=======News for 9/17======
Stock woes are worrying investors
Business outlook is optimistic despite slow growth
=======News for 9/16======
More people moving into big cities
Stay ahead of the flu this year
You can try out this one http://groupgridview.demopage.ru/ or this http://www.yiiframework.com/extension/xdateview/ . And you can create your custom gridview basing on this two above, goodluck.
这篇关于如何在Yii CListView中按日期分组项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!