@@ -46,11 +46,9 @@ function renderAsButtonWrapper(renderer) {
4646 return < > </ > ;
4747 }
4848 return (
49- < Button
50- style = { { width : '100%' , marginLeft : '5px' , marginRight : '5px' } }
51- variant = 'contained'
52- color = 'primary'
53- > { outputValue } </ Button >
49+ < Button style = { { width : '100%' , marginLeft : '5px' , marginRight : '5px' } } variant = 'contained' color = 'primary' >
50+ { outputValue }
51+ </ Button >
5452 ) ;
5553 } ;
5654}
@@ -73,6 +71,7 @@ export const generateSafeColumnKey = (key) => {
7371
7472export const NeoTableChart = ( props : ChartProps ) => {
7573 const transposed = props . settings && props . settings . transposed ? props . settings . transposed : false ;
74+ const wrapContent = props . settings && props . settings . wrapContent ? props . settings . wrapContent : false ;
7675 const allowDownload =
7776 props . settings && props . settings . allowDownload !== undefined ? props . settings . allowDownload : false ;
7877
@@ -214,6 +213,49 @@ export const NeoTableChart = (props: ChartProps) => {
214213 : Math . floor ( availableRowHeight ) - pageSizeReducer ;
215214
216215 const pageNames = getPageNumbersAndNamesList ( ) ;
216+ const commonGridProps = {
217+ key : 'tableKey' ,
218+ headerHeight : 32 ,
219+ density : compact ? 'compact' : 'standard' ,
220+ rows : rows ,
221+ columns : columns ,
222+ columnVisibilityModel : columnVisibilityModel ,
223+ onColumnVisibilityModelChange : ( newModel ) => setColumnVisibilityModel ( newModel ) ,
224+ onCellClick : ( e ) => performActionOnElement ( e , actionsRules , { ...props , pageNames : pageNames } , 'Click' , 'Table' ) ,
225+ onCellDoubleClick : ( e ) => {
226+ let rules = getRule ( e , actionsRules , 'doubleClick' ) ;
227+ if ( rules !== null ) {
228+ rules . forEach ( ( rule ) => executeActionRule ( rule , e , { ...props , pageNames : pageNames } , 'table' ) ) ;
229+ } else {
230+ setNotificationOpen ( true ) ;
231+ navigator . clipboard . writeText ( e . value ) ;
232+ }
233+ } ,
234+ checkboxSelection : hasCheckboxes ( actionsRules ) ,
235+ selectionModel : getCheckboxes ( actionsRules , rows , props . getGlobalParameter ) ,
236+ onSelectionModelChange : ( selection ) => updateCheckBoxes ( actionsRules , rows , selection , props . setGlobalParameter ) ,
237+ pageSize : tablePageSize > 0 ? tablePageSize : 5 ,
238+ rowsPerPageOptions : rows . length < 5 ? [ rows . length , 5 ] : [ 5 ] ,
239+ disableSelectionOnClick : true ,
240+ components : {
241+ ColumnSortedDescendingIcon : ( ) => < > </ > ,
242+ ColumnSortedAscendingIcon : ( ) => < > </ > ,
243+ } ,
244+ getRowClassName : ( params ) => {
245+ return [ 'row color' , 'row text color' ]
246+ . map ( ( e ) => {
247+ return `rule${ evaluateRulesOnDict ( params . row , styleRules , [ e ] ) } ` ;
248+ } )
249+ . join ( ' ' ) ;
250+ } ,
251+ getCellClassName : ( params ) => {
252+ return [ 'cell color' , 'cell text color' ]
253+ . map ( ( e ) => {
254+ return `rule${ evaluateRulesOnDict ( { [ params . field ] : params . value } , styleRules , [ e ] ) } ` ;
255+ } )
256+ . join ( ' ' ) ;
257+ } ,
258+ } ;
217259
218260 return (
219261 < ThemeProvider theme = { theme } >
@@ -259,61 +301,21 @@ export const NeoTableChart = (props: ChartProps) => {
259301 < > </ >
260302 ) }
261303
262- < DataGrid
263- key = { 'tableKey' }
264- headerHeight = { 32 }
265- density = { compact ? 'compact' : 'standard' }
266- getRowHeight = { ( ) => 'auto' }
267- rows = { rows }
268- columns = { columns }
269- columnVisibilityModel = { columnVisibilityModel }
270- onColumnVisibilityModelChange = { ( newModel ) => setColumnVisibilityModel ( newModel ) }
271- onCellClick = { ( e ) =>
272- performActionOnElement ( e , actionsRules , { ...props , pageNames : pageNames } , 'Click' , 'Table' )
273- }
274- onCellDoubleClick = { ( e ) => {
275- let rules = getRule ( e , actionsRules , 'doubleClick' ) ;
276- if ( rules !== null ) {
277- rules . forEach ( ( rule ) => executeActionRule ( rule , e , { ...props , pageNames : pageNames } , 'table' ) ) ;
278- } else {
279- setNotificationOpen ( true ) ;
280- navigator . clipboard . writeText ( e . value ) ;
281- }
282- } }
283- checkboxSelection = { hasCheckboxes ( actionsRules ) }
284- selectionModel = { getCheckboxes ( actionsRules , rows , props . getGlobalParameter ) }
285- onSelectionModelChange = { ( selection ) =>
286- updateCheckBoxes ( actionsRules , rows , selection , props . setGlobalParameter )
287- }
288- pageSize = { tablePageSize > 0 ? tablePageSize : 5 }
289- rowsPerPageOptions = { rows . length < 5 ? [ rows . length , 5 ] : [ 5 ] }
290- disableSelectionOnClick
291- components = { {
292- ColumnSortedDescendingIcon : ( ) => < > </ > ,
293- ColumnSortedAscendingIcon : ( ) => < > </ > ,
294- } }
295- getRowClassName = { ( params ) => {
296- return [ 'row color' , 'row text color' ]
297- . map ( ( e ) => {
298- return `rule${ evaluateRulesOnDict ( params . row , styleRules , [ e ] ) } ` ;
299- } )
300- . join ( ' ' ) ;
301- } }
302- getCellClassName = { ( params ) => {
303- return [ 'cell color' , 'cell text color' ]
304- . map ( ( e ) => {
305- return `rule${ evaluateRulesOnDict ( { [ params . field ] : params . value } , styleRules , [ e ] ) } ` ;
306- } )
307- . join ( ' ' ) ;
308- } }
309- sx = { {
310- '&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell' : { py : '3px' } ,
311- '&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell:has(button)' : { py : '0px' } ,
312- '&.MuiDataGrid-root--densityStandard .MuiDataGrid-cell' : { py : '15px' } ,
313- '&.MuiDataGrid-root--densityComfortable .MuiDataGrid-cell' : { py : '22px' } ,
314- '&.MuiDataGrid-root .MuiDataGrid-cell' : { wordBreak : 'break-word' } ,
315- } }
316- />
304+ { wrapContent ? (
305+ < DataGrid
306+ { ...commonGridProps }
307+ getRowHeight = { ( ) => 'auto' }
308+ sx = { {
309+ '&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell' : { py : '3px' } ,
310+ '&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell:has(button)' : { py : '0px' } ,
311+ '&.MuiDataGrid-root--densityStandard .MuiDataGrid-cell' : { py : '15px' } ,
312+ '&.MuiDataGrid-root--densityComfortable .MuiDataGrid-cell' : { py : '22px' } ,
313+ '&.MuiDataGrid-root .MuiDataGrid-cell' : { wordBreak : 'break-word' } ,
314+ } }
315+ />
316+ ) : (
317+ < DataGrid { ...commonGridProps } rowHeight = { tableRowHeight } />
318+ ) }
317319 </ div >
318320 </ ThemeProvider >
319321 ) ;
0 commit comments