在slickgrid中如何进行多列分组? [英] How multiple column grouping can be done in slickgrid?

查看:159
本文介绍了在slickgrid中如何进行多列分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是slickgrid的新手.我已经讲了一些关于slickgrid的例子,并且对基础知识也很满意.我有一种情况,我需要基于多个列进行分组,但是slickgrid分组是基于单个列.

Im a newbie to slickgrid. I have gone through few examples of slickgrid and good with basics. I have a scenario where i need grouping based on multiple columns but slickgrid grouping is based on a single column.

如何在slickgrid中完成对每个组的扩展和折叠功能的多列列分组?

How can multilpe column grouping done in slickgrid with expand and collapse functionality on each group?

自从对slickgrid陌生以来,任何意识到这一解决方案的人都以一种基本的方式进行解释.

Anyone who is aware of the solution for this,kindly explain in a basic way since im new to slickgrid.

我的要求就像在此链接中对行本身进行分组一样 slickgrid-grouping-example .本示例用于基于一列的分组.我的要求是基于多个列进行分组

My requirement is like grouping the rows itself as in this link slickgrid-grouping-example. This example is for grouping based on one column. My requirement is to group based on multiple columns

推荐答案

我知道问题已经老了,但是不久前我实现了此功能,并以我的名字在Github上的SlickGrid projet队列中收到了拉取请求.您也许可以尝试一下,并给我一些反馈.为此,我修改了3个文件,包括示例文件.在这一点上,我不知道我的提交是否会被接受,因此请您自担风险,尽管我对自己的解决方案非常有信心,因为我已经在工作中使用它了. 这是它的链接: https://github.com/mleibman/SlickGrid/pull/522/文件

I know the question is getting old but I made this functionality possible not long ago and got a pull request in the queue of SlickGrid projet on Github under my name. You could maybe try it out and give me some feedback. I modified 3 files to do so, including the example file. At this point, I do not know if my commit will be accepted or not, so try it at your own risk, though I'm very confident about my solution as I am already using it at work. Here is the link to it: https://github.com/mleibman/SlickGrid/pull/522/files

这里是3个多列分组的示例,此代码部分也来自我修改过的example-grouping.html文件.定义多个分组可以使用数组,这与以前的实现非常相似,只是在定义多个分组时将其包装在数组中即可.

Here is an example of 3 multiple columns grouping, this code portion comes from the example-grouping.html file which I modified as well. Defining multiple grouping works with arrays, very similar to previous implementation, just wrap it in arrays when defining multiple grouping.

function groupByDurationPercentageStart() {
  dataView.groupBy(
    ["duration", "percentComplete", "start"],
    [
      (function (g) {
        return "Duration:  " + g.value + "  <span style='color:green'>(" + g.count + " items)</span>";
      }),
      (function (g) {
        return "Complete:  " + g.value + "  <span style='color:green'>(" + g.count + " items)</span>";
      }),
      (function (g) {
        return "Start Date:  " + g.value + "  <span style='color:green'>(" + g.count + " items)</span>";
      })
    ],
    [
      function (a, b) {
        return a.value - b.value;
      },
      function (a, b) {
        return a.value - b.value;
      },
      function (a, b) { // string sorting
        var x = a.value, y = b.value;
        return x == y ? 0 : (x > y ? 1 : -1);
      }
    ]
  ); 
  dataView.setAggregators([
    new Slick.Data.Aggregators.Avg("percentComplete"),
    new Slick.Data.Aggregators.Sum("cost")
  ], true, false);     
}

希望它对您有帮助,现在它确实具有所有功能,我喜欢这个网格=)

Hope it helps you guys, now it really does have all features, I love this grid =)

这篇关于在slickgrid中如何进行多列分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆