Hide group rows of dc.dataTable

假装没事ソ 提交于 2019-12-11 11:09:59

问题


I am using the JavaScript library dc.js to dynamically generate a table of records using the dc.dataTable(). The data is rather simple, so I actually want to show it as a plain list of rows without any grouping.

However, dc.dataTable() requires a .group() attribute. Each such group is then shown with an extra row in the resulting table before its data rows.

var datatable = dc.dataTable("#category-table");
    datatable
        .dimension(categoryDim)
        .group(function(d) {return "Categories";}) //just 1 static group, so it's only 1 unnecessary group label row at least
        .columns([
          function(d) { return d.category_name; },
          function(d) { return d.views;},
        ]);

If I skip the .group() part, I get

Mandatory attribute chart.group is missing on chart

Is there any way to hide these group label rows or skip the grouping altogether?


回答1:


Hiding the table group rows is possible using css. These added rows have the css class dc-table-group and can therefore be hidden using some custom css:

.dc-table-group {
  visibility: collapse;
}



回答2:


Update 2019:

As of version 3.0.12 you can hide the group (or section) header with .showGroups(false).

Docs: https://dc-js.github.io/dc.js/docs/html/dc.dataTable.html#showGroups__anchor



来源:https://stackoverflow.com/questions/29343076/hide-group-rows-of-dc-datatable

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