Question

I'm using dc.js to plot chart and show data tables.

Everything runs quite good. And for the table i've created a dimension and also a group. Passing the group variable to dynatable records.

Problem is when I do some selection in the chart. The data table value are of course getting changed. But the there are few records which are supposed to hidden instead they come with 0 value.

I wanted to hide those rows.

Below are the functions I'm using.

Table Dimension : var tableDim = ndx.dimension(function(d) { return d.label; })

Table Group: var tableGroup = tableDim.group().reduceSum(function(d) { return d.count; })

Dyna Table:

var dynatable = $('.data-table').dynatable({
        features: {
            pushState: false
        },
        dataset: {
            records: tableGroup.top(Infinity),
            perPageDefault: 10,
            perPageOptions: [10, 20, 100, 500, 1000]
        }
    }).data('dynatable');

Refresh the table on chart selection :

function RefreshTable() {
        dc.events.trigger(function () {
            dynatable.settings.dataset.originalRecords = tableGroup.top(Infinity);
            dynatable.process();
        });

        $('.data-table tr').each(function() {
            if ($(this).find('td:nth-child(2)').text() < 1) {
                $(this).addClass('zero-value');
            }
        })
    };

I've written jquery codes to assign a class for the rows with zero-value. And it gets assigns only for the first 10 records as I've given the perPageDefault: 10. But I want to it run for the entire table records.

Some one please help me in hiding those rows with values 0.

Was it helpful?

Solution

Before assigning the records in the dynaTable initialization and RefreshTable, you can copy the data and remove records that have value 0.

Dynatable is acting on the records that you pass it, so you can change that data in any way you see fit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top