Refresh group header to show sum of values in group

In Tabulator, I have a group header that shows calculated data, the grouping itself doesn’t depend on this calculated data, I need to update a cell which is not used by the grouping and refresh the group.

Consider this example, In the group header I’m showing the sum of hours by group, update the cell “hours”, and the header will not update because the hours column is not being used by the grouping function, how can I refresh the header?

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
var myTable = null;
$(() => {
var tableDiv = document.querySelector("#tableDiv");
console.log(tableDiv);
var tableData = [
{ id: 1, name: "Oli Bob", age: "12", hours: 1 },
{ id: 2, name: "Mary May", age: "12", hours: 2 },
{ id: 3, name: "Christine Lobowski", age: "42", hours: 3 },
{ id: 4, name: "Brendon Philips", age: "125", hours: 5 },
{ id: 5, name: "Margret Marmajuke", age: "16", hours: 1 },
{ id: 6, name: "Oli Bob", age: "12", hours: 1 },
{ id: 7, name: "Mary May", age: "12", hours: 2 },
{ id: 8, name: "Christine Lobowski", age: "42", hours: 4 },
{ id: 9, name: "Brendon Philips", age: "125", hours: 5 },
{ id: 10, name: "Margret Marmajuke", age: "16", hours: 2 },
];
for (i = 11; i <= 200; i++) {
tableData.push(
{ id: i, name: window.crypto.randomUUID(), age: i, hours: i }
);
}
var columnConfig = [
{ title: "Name", field: "name", width: 150 },
{ title: "Age", field: "age", hozAlign: "left", editor: "input" },
{ title: "Hours", field: "hours", width: 150, editor: "number" },
];
myTable = new Tabulator(tableDiv, {
data: tableData,
columns: columnConfig,
//height: "200px",
groupBy: function (data) {
//data - the data object for the row being grouped
return data.age; //groups by age
},
groupHeader: function (value, count, data, group) {
//value - the value all members of this group share
//count - the number of rows in this group
//data - an array of all the row data objects in this group
//group - the group component for the group
return `Age: ${value} - Hours: ${data.map(i => i.hours).reduce((a, b) => a + b)}`;
},
groupUpdateOnCellEdit: true,
maxHeight: "100%"
});
myTable.on('cellEdited', (c) => {
//what can I do here?
});
})</code>
<code> var myTable = null; $(() => { var tableDiv = document.querySelector("#tableDiv"); console.log(tableDiv); var tableData = [ { id: 1, name: "Oli Bob", age: "12", hours: 1 }, { id: 2, name: "Mary May", age: "12", hours: 2 }, { id: 3, name: "Christine Lobowski", age: "42", hours: 3 }, { id: 4, name: "Brendon Philips", age: "125", hours: 5 }, { id: 5, name: "Margret Marmajuke", age: "16", hours: 1 }, { id: 6, name: "Oli Bob", age: "12", hours: 1 }, { id: 7, name: "Mary May", age: "12", hours: 2 }, { id: 8, name: "Christine Lobowski", age: "42", hours: 4 }, { id: 9, name: "Brendon Philips", age: "125", hours: 5 }, { id: 10, name: "Margret Marmajuke", age: "16", hours: 2 }, ]; for (i = 11; i <= 200; i++) { tableData.push( { id: i, name: window.crypto.randomUUID(), age: i, hours: i } ); } var columnConfig = [ { title: "Name", field: "name", width: 150 }, { title: "Age", field: "age", hozAlign: "left", editor: "input" }, { title: "Hours", field: "hours", width: 150, editor: "number" }, ]; myTable = new Tabulator(tableDiv, { data: tableData, columns: columnConfig, //height: "200px", groupBy: function (data) { //data - the data object for the row being grouped return data.age; //groups by age }, groupHeader: function (value, count, data, group) { //value - the value all members of this group share //count - the number of rows in this group //data - an array of all the row data objects in this group //group - the group component for the group return `Age: ${value} - Hours: ${data.map(i => i.hours).reduce((a, b) => a + b)}`; }, groupUpdateOnCellEdit: true, maxHeight: "100%" }); myTable.on('cellEdited', (c) => { //what can I do here? }); })</code>
   
var myTable = null;
$(() => {
    var tableDiv = document.querySelector("#tableDiv");
    console.log(tableDiv);
    var tableData = [
        { id: 1, name: "Oli Bob", age: "12", hours: 1 },
        { id: 2, name: "Mary May", age: "12", hours: 2 },
        { id: 3, name: "Christine Lobowski", age: "42", hours: 3 },
        { id: 4, name: "Brendon Philips", age: "125", hours: 5 },
        { id: 5, name: "Margret Marmajuke", age: "16", hours: 1 },
        { id: 6, name: "Oli Bob", age: "12", hours: 1 },
        { id: 7, name: "Mary May", age: "12", hours: 2 },
        { id: 8, name: "Christine Lobowski", age: "42", hours: 4 },
        { id: 9, name: "Brendon Philips", age: "125", hours: 5 },
        { id: 10, name: "Margret Marmajuke", age: "16", hours: 2 },

    ];

    for (i = 11; i <= 200; i++) {
        tableData.push(
            { id: i, name: window.crypto.randomUUID(), age: i, hours: i }
        );
    }

    var columnConfig = [
        { title: "Name", field: "name", width: 150 },
        { title: "Age", field: "age", hozAlign: "left", editor: "input" },
        { title: "Hours", field: "hours", width: 150, editor: "number" },
    ];

    myTable = new Tabulator(tableDiv, {
        data: tableData,
        columns: columnConfig,
        //height: "200px",
        groupBy: function (data) {
            //data - the data object for the row being grouped
            return data.age; //groups by age
        },
        groupHeader: function (value, count, data, group) {
            //value - the value all members of this group share
            //count - the number of rows in this group
            //data - an array of all the row data objects in this group
            //group - the group component for the group

            return `Age: ${value} - Hours: ${data.map(i => i.hours).reduce((a, b) => a + b)}`;
        },
        groupUpdateOnCellEdit: true,
        maxHeight: "100%"


    });


    myTable.on('cellEdited', (c) => {
      //what can I do here?
    });



})
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>div.example-table {
height: 400px;
}</code>
<code>div.example-table { height: 400px; }</code>
div.example-table {
    height: 400px;  
  }
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" 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 type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script type="text/javascript" src="./index.js"></script>
<link href="./index.css" rel="stylesheet">
<title>Simple HTML Page</title>
<style>
</style>
</head>
<body>
<div id="tableDiv" class="example-table"></div>
</body>
</html></code>
<code><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- <link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet"> <script type="text/javascript" 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 type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script> <script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script> <script type="text/javascript" src="./index.js"></script> <link href="./index.css" rel="stylesheet"> <title>Simple HTML Page</title> <style> </style> </head> <body> <div id="tableDiv" class="example-table"></div> </body> </html></code>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- <link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
    <script type="text/javascript" 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 type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>

    <script src="https://code.jquery.com/jquery-3.7.1.min.js"
        integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
    <script type="text/javascript" src="./index.js"></script>
    <link href="./index.css" rel="stylesheet">
    <title>Simple HTML Page</title>
    <style>

    </style>
</head>

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

</html>

I can use the cellEdited callback to update the group, but how?

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> myTable.on('cellEdited', (c) => {
//what can I do here?
});
</code>
<code> myTable.on('cellEdited', (c) => { //what can I do here? }); </code>
        myTable.on('cellEdited', (c) => {
          //what can I do here?
        });

Things I have tried:

Redraw the table

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> myTable.on('cellEdited', (c) => {
myTable.redraw(); //does nothing
});
</code>
<code> myTable.on('cellEdited', (c) => { myTable.redraw(); //does nothing }); </code>
        myTable.on('cellEdited', (c) => {
          myTable.redraw(); //does nothing
        });

Redraw full

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> myTable.on('cellEdited', (c) => {
myTable.redraw(true); //works but the vertical scroll jumps to the top
});
</code>
<code> myTable.on('cellEdited', (c) => { myTable.redraw(true); //works but the vertical scroll jumps to the top }); </code>
        myTable.on('cellEdited', (c) => {
          myTable.redraw(true); //works but the vertical scroll jumps to the top
        });

refreshActiveData

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> myTable.on('cellEdited', (c) => {
myTable.rowManager.refreshActiveData(); //works but the vertical scroll jumps to the top
});
</code>
<code> myTable.on('cellEdited', (c) => { myTable.rowManager.refreshActiveData(); //works but the vertical scroll jumps to the top }); </code>
        myTable.on('cellEdited', (c) => {
          myTable.rowManager.refreshActiveData(); //works but the vertical scroll jumps to the top
        });

If I remove the height of the table the scroll problem goes away, but I lose the frozen column headers

What can be done?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật