Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dc datatable without grouping the rows

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

like image 471
J86 Avatar asked Nov 07 '14 14:11

J86


2 Answers

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

like image 130
Gordon Avatar answered Nov 01 '22 21:11

Gordon


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.

like image 20
Daniel777 Avatar answered Nov 01 '22 23:11

Daniel777