Skip to main content

Enable and Disable Columns

Enable

Optional param. Pass the names of columns as list. Use it when your json data contains so many garbage that you want only few columns to be visible.

const { Table } = require("console-table-printer");

const p = new Table({
enabledColumns: ["id", "text"],
});

// add rows with color
p.addRows([
{
id: 2,
text: "This row is some shit",
garbages: 10.212,
},
{
id: 3,
text: "I would like some more text",
garbages: 10.212,
},
{
id: 4,
text: "I would like some text",
garbages: "some garbase shit that I dont want to see",
},
]);

p.printTable();
Screenshot

Disable

This one was good incase you a short listed disabled columns.

const { Table } = require("console-table-printer");

const p = new Table({
disabledColumns: ["garbages"],
});

// add rows with color
p.addRows([
{
good_text: "This row is some shit",
id: "1",
garbages: 10.212,
},
{
id: "2",
good_text: "I would like some more text",
garbages: 10.212,
},
{
id: "3",
good_text: "I would like some text",
garbages: "some garbase shit that I dont want to see",
},
]);

p.printTable();
Screenshot