Skip to content

Commit ff3af6e

Browse files
committed
ui: Datagrid disabled sorting and filtering unnecessarily
1 parent e4433db commit ff3af6e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ui/src/components/widgets/datagrid/datagrid.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
475475
const columnsAreMutable = !columns || !!attrs.onColumnsChanged;
476476

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

480481
// Determine if we're in pivot mode (has groupBy columns and not drilling down)
481482
const isPivotMode =
@@ -1443,11 +1444,10 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
14431444
// Build menu items
14441445
const columnType = colInfo?.columnType;
14451446
const menuItems: m.Children[] = [
1446-
columnsAreMutable &&
1447-
renderSortMenuItems(sort, (direction) =>
1448-
this.updateSort(field, direction, attrs),
1449-
),
1450-
columnsAreMutable && m(MenuDivider),
1447+
renderSortMenuItems(sort, (direction) =>
1448+
this.updateSort(field, direction, attrs),
1449+
),
1450+
m(MenuDivider),
14511451
filtersAreMutable &&
14521452
m(FilterMenu, {
14531453
datasource,
@@ -1549,11 +1549,9 @@ export class DataGrid implements m.ClassComponent<DataGridAttrs> {
15491549
header: m(
15501550
GridHeaderCell,
15511551
{
1552-
sort: columnsAreMutable ? sort : undefined,
1552+
sort,
15531553
hintSortDirection: currentSortDirection,
1554-
onSort: columnsAreMutable
1555-
? (direction) => this.updateSort(colId, direction, attrs)
1556-
: undefined,
1554+
onSort: (direction) => this.updateSort(colId, direction, attrs),
15571555
menuItems,
15581556
subContent,
15591557
},

0 commit comments

Comments
 (0)