dc datatable without grouping the rows

£可爱£侵袭症+ 提交于 2020-01-02 02:43:07

问题


Is it possible to have a dc data table without showing the data in groups? I just want to show all the data across all groups!

My code is as follows:

dc.dataTable(".dc-data-table")
  .dimension(dateDimension)
  .group(function (d) {
    return ''
  })
  .size(10) // (optional) max number of records to be shown, :default = 25
  .columns([
      function (d) {
          return getFormattedDate(d.dd);
      },
      function (d) {
          return d.referredfor;
      },
      function (d) {
          return numberFormat(d.cost);
      },
      function (d) {
          return d.gender;
      }
  ])
  .sortBy(function (d) {
      return d.dd;
  })
  .order(d3.ascending)
  .renderlet(function (table) {
      table.selectAll(".dc-table-group").classed("info", true);
  });

This shows my data table but with an empty row like so:


回答1:


It doesn't look like there is currently a way to do this. Sounds like a reasonable request! You might submit an enhancement request, or even better, a PR.

Here is the relevant code, in renderGroups:

https://github.com/dc-js/dc.js/blob/master/src/data-table.js#L121

It is nesting the data by key and then adding a table row for each group. It would be trivial to disable this, but the problem is that later, renderRows selects those "group rows" in order to add data under them:

https://github.com/dc-js/dc.js/blob/master/src/data-table.js#L156

EDIT: it's an option, .showGroups(), as of 2.0 beta 16




回答2:


A simple workaround:

You can override the corresponding css class to avoid display of that row, by using:

<style>
  .dc-table-group{display:none}
</style>

in your html.



来源:https://stackoverflow.com/questions/26803161/dc-datatable-without-grouping-the-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!