dc datatable without grouping the rows
Asked Answered
S

2

9

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:

datatable

Shue answered 7/11, 2014 at 14:11 Comment(0)
N
10

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

Nilgai answered 8/11, 2014 at 19:29 Comment(0)
H
5

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.

Hydroquinone answered 15/5, 2015 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.