Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions ui/src/components/widgets/datagrid/datagrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
const columnsAreMutable = !columns || !!attrs.onColumnsChanged;

// Filters are mutable if in uncontrolled mode, or controlled with callback
const filtersAreMutable = !filters || !!attrs.onFiltersChanged;
const filtersAreMutable =
!filters || !!attrs.onFiltersChanged || !!attrs.onFilterAdd;

// Determine if we're in pivot mode (has groupBy columns and not drilling down)
const isPivotMode =
Expand Down Expand Up @@ -1443,11 +1444,10 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
// Build menu items
const columnType = colInfo?.columnType;
const menuItems: m.Children[] = [
columnsAreMutable &&
renderSortMenuItems(sort, (direction) =>
this.updateSort(field, direction, attrs),
),
columnsAreMutable && m(MenuDivider),
renderSortMenuItems(sort, (direction) =>
this.updateSort(field, direction, attrs),
),
m(MenuDivider),
filtersAreMutable &&
m(FilterMenu, {
datasource,
Expand Down Expand Up @@ -1549,11 +1549,9 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
header: m(
GridHeaderCell,
{
sort: columnsAreMutable ? sort : undefined,
sort,
hintSortDirection: currentSortDirection,
onSort: columnsAreMutable
? (direction) => this.updateSort(colId, direction, attrs)
: undefined,
onSort: (direction) => this.updateSort(colId, direction, attrs),
menuItems,
subContent,
},
Expand Down
Loading