Shrishanth s rao
Shrishanth s rao

Reputation: 28

How to disable item count while grouping data?

I have a table in which data gets grouped based on some specific field. I am using Tabulator.JS to convert the JSON data into a table. Grouping property is working as required but the result displays number of items in that group. I need to disable this item count feature.

I have used Tabulator's "groupBy" feature to group the data. I am not sure whether I should write a custom function to display the group header or is there an inbuilt feature to disable the item count.

I use the following function to load the tabulator.

function reloadTabulator() {
    ScheduleTable = new Tabulator("#ClassScheduleDiv", {
        placeholder: "No Content",
        layout: "fitColumns",
        columns: [
        { title: "Start Time", field: "StartTime", sorter: "number" },
        { title: "Class Name", field: "ClassName", sorter: "string" },
        { title: "Instructor", field: "StaffName", sorter: "string" },
        { title: "Availabilty", field: "Availability", sorter: "string", 
        formatter: GetBookNowButton },
        { title: "Duration", field: "Duration", sorter: "string" }
        ],
        groupBy: ["ClassStartDate"],
        groupStartOpen: [true]
    });
}

I use table.setData(Dataset) function to set the data to table as follows:

ScheduleTable.setData(MyJSON);

Current Output: Current Output Image

Expected Output: Expected Output Image

Upvotes: 0

Views: 571

Answers (1)

dota2pro
dota2pro

Reputation: 7866

.tabulator-row>span {
  display: none;
}

const tabledata1 = [{
    id: 1,
    name: "Oli ",
    money: "0",
    col: "red",
    dob: ""
  },
  {
    id: 2,
    name: "Mary ",
    money: "0",
    col: "blue",
    dob: "14/05/1982",
    gender: 'male'
  },
  {
    id: 3,
    name: "Christine ",
    money: "0",
    col: "green",
    dob: "22/05/1982",
    gender: 'female'

  },
  {
    id: 4,
    name: "Brendon ",
    money: "0",
    col: "orange",
    dob: "01/08/1980",
    gender: 'male'

  },
  {
    id: 5,
    name: "Margret ",
    money: "0",
    col: "yellow",
    dob: "31/01/1999",
    gender: 'male'

  },
];

const columns = [ //Define Table Columns
  {
    title: "Name",
    field: "name",
    width: 150
  },
  {
    title: "money",
    field: "money",
    align: "left",
    formatter: "money"
  },
  {
    title: "Favourite Color",
    field: "col"
  },
  {
    title: "Date Of Birth",
    field: "dob",
    sorter: "date",
    align: "center"
  }, {
    title: "Gender",
    field: "gender"
  }
];


const table = new Tabulator("#example-table", {
  placeholder: "No Content",
  data: tabledata1, //load row data from array

  layout: "fitColumns",
  movableRows: true,
  groupBy: ["ClassStartDate"],
  groupStartOpen: [true],
  columns: columns
});
const removeArrow = function() {
  table.setColumns(col2);
}


$('#removeArrow').click(function() {
  removeArrow();
});
.tabulator-row>span {
  display: none;
}
<!DOCTYPE html>
<html lang="en">

<script src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<body>
  <div id="example-table"></div>
</body>

</html>

Upvotes: 0

Related Questions