I am fairly new to JavaScript and am currently learning how to work with Tabulator (which is working quite nicely aside from this problem).
I want to add a menu button to every column header, which then opens a dropdown menu. From this menu the user should have the ability to select "Group By" and then have the table group data using the selected column.
The button in question would be:
<div class="ui icon top left pointing dropdown button" id=dropdown>
<i class="bars icon"></i>
<div class="menu">
<div class="header">Options</div>
<div class="item">Test</div>
</div>
</div>
And would look like this:
And this is my current columnData:
var table = new Tabulator("#example-table",{
data:tabledata,
layout:"fitColumns",
locale:true,
movableColumns:true,
resizableColumns:false,
columns:[
{title:"Name", field:"name", headerFilter:"input"},
{title:"Age", field:"age", align:"right", sorter:"number", headerFilter:"number", /* bottomCalc:"sum" */},
{title:"Favorite Color", field:"col", headerFilter:"input"},
{title:"Date of Birth", field:"dob", sorter:"date", align:"center", headerFilter:"input", headerContext:function(e, column){
table.setGroupBy(column.getField());
e.preventDefault();
},
},
{title:"Nationality", field:"nationality", headerFilter:"input", headerContext:function(e, column){
table.setGroupBy(column.getField());
e.preventDefault();
},
},
],
langs:{
"de-de":{
"headerFilters":{
"default":"Spalte filtern...",
}
}
},
});
See Question&Answers more detail:
os