emberjs 按年月分组

一个集合,里面有年和月的属性,按照年和月进行分组显示数据

 var groupByYearMonth = _.chain(topics).groupBy(function (item) { return item.TopicYear * 100 + item.TopicMonth }).map(function (value, key) {
                            return {
                                time: {
                                    year: value[0].TopicYear + '',
                                    month: value[0].TopicMonth + ''
                                },
                                list: value
                            };
                        }).value();

topics是数据集合

ps:需要引入underscore.js

posted @ 2015-01-07 16:51  红鲤鱼与驴与绿鲤鱼  阅读(157)  评论(0编辑  收藏  举报