@@ -10,7 +10,12 @@ import {
1010 useFilterContext ,
1111 useMultipleFiltering
1212} from "@mendix/pluggable-widgets-commons/components/web" ;
13- import { isAvailable , useSelectionHelper } from "@mendix/pluggable-widgets-commons" ;
13+ import {
14+ getGlobalSelectionContext ,
15+ isAvailable ,
16+ useCreateSelectionContextValue ,
17+ useSelectionHelper
18+ } from "@mendix/pluggable-widgets-commons" ;
1419import { extractFilters } from "./features/filters" ;
1520import { useCellRenderer } from "./features/cell" ;
1621import { getColumnAssociationProps , isSortable } from "./features/column" ;
@@ -29,6 +34,7 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement {
2934 const [ filtered , setFiltered ] = useState ( false ) ;
3035 const multipleFilteringState = useMultipleFiltering ( ) ;
3136 const { FilterContext } = useFilterContext ( ) ;
37+ const SelectionContext = getGlobalSelectionContext ( ) ;
3238 const cellRenderer = useCellRenderer ( { columns : props . columns , onClick : props . onClick } ) ;
3339
3440 useEffect ( ( ) => {
@@ -120,6 +126,8 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement {
120126 const selectActionProps = useOnSelectProps ( selection ) ;
121127 const { selectionStatus, selectionMethod } = selectionSettings ( props , selection ) ;
122128
129+ const selectionContextValue = useCreateSelectionContextValue ( selection ) ;
130+
123131 return (
124132 < Table
125133 selectionStatus = { selectionStatus }
@@ -169,10 +177,9 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement {
169177 } ,
170178 [ FilterContext , customFiltersState , props . columns ]
171179 ) }
172- filtersTitle = { props . filterSectionTitle ?. value }
173180 hasMoreItems = { props . datasource . hasMoreItems ?? false }
174181 headerWrapperRenderer = { useCallback ( ( _columnIndex : number , header : ReactElement ) => header , [ ] ) }
175- headerFilters = { useMemo (
182+ gridHeaderWidgets = { useMemo (
176183 ( ) => (
177184 < FilterContext . Provider
178185 value = { {
@@ -188,11 +195,14 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement {
188195 multipleInitialFilters
189196 } }
190197 >
191- { props . filtersPlaceholder }
198+ < SelectionContext . Provider value = { selectionContextValue } >
199+ { props . filtersPlaceholder }
200+ </ SelectionContext . Provider >
192201 </ FilterContext . Provider >
193202 ) ,
194203 [ FilterContext , filterList , multipleInitialFilters , props . filtersPlaceholder , multipleFilteringState ]
195204 ) }
205+ gridHeaderTitle = { props . filterSectionTitle ?. value }
196206 id = { id . current }
197207 numberOfItems = { props . datasource . totalCount }
198208 page = { currentPage }
0 commit comments