File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
chartlets.js/packages/lib/src/plugins/mui Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ describe("DataGrid", () => {
5050 expect ( recordedEvents [ 0 ] . componentType ) . toBe ( "DataGrid" ) ;
5151 expect ( recordedEvents [ 0 ] . id ) . toBe ( "datagridId" ) ;
5252 expect ( recordedEvents [ 0 ] . property ) . toBe ( "value" ) ;
53- expect ( recordedEvents [ 0 ] . value ) . toEqual ( mockRows [ 0 ] ) ;
53+ expect ( recordedEvents [ 0 ] . value ) . toEqual ( mockRows ) ;
5454 } ) ;
5555
5656 it ( "should render with other props correctly" , ( ) => {
Original file line number Diff line number Diff line change 11import {
22 DataGrid as MuiDataGrid ,
3- type GridCallbackDetails ,
43 type GridColDef ,
54 type GridPaginationModel ,
65 type GridRowModel ,
7- type GridRowParams ,
8- type MuiEvent ,
6+ type GridRowSelectionModel ,
97} from "@mui/x-data-grid" ;
108import type { ComponentProps , ComponentState } from "@/index" ;
119
@@ -78,17 +76,16 @@ export const DataGrid = ({
7876 return ;
7977 }
8078
81- const handleClick = (
82- params : GridRowParams ,
83- _event : MuiEvent ,
84- _details : GridCallbackDetails ,
85- ) => {
79+ const onRowsSelectionHandler = ( ids : GridRowSelectionModel ) => {
8680 if ( id ) {
81+ const selectedRowsData = ids . map ( ( id ) =>
82+ rows ?. find ( ( row ) => row . id === id ) ,
83+ ) ;
8784 onChange ( {
8885 componentType : type ,
8986 id : id ,
9087 property : "value" ,
91- value : params . row ,
88+ value : selectedRowsData ,
9289 } ) ;
9390 }
9491 } ;
@@ -117,7 +114,7 @@ export const DataGrid = ({
117114 hideFooterPagination = { hideFooterPagination }
118115 initialState = { initialState }
119116 loading = { loading }
120- onRowClick = { handleClick }
117+ onRowSelectionModelChange = { onRowsSelectionHandler }
121118 paginationModel = { paginationModel }
122119 pageSizeOptions = { pageSizeOptions }
123120 rowHeight = { rowHeight }
You can’t perform that action at this time.
0 commit comments