@@ -10,13 +10,15 @@ import {
1010 type Column ,
1111 type GridOption ,
1212 type Grouping ,
13+ type OnFormattedDataCacheCompletedEventArgs ,
1314 type SliderOption ,
1415} from '@slickgrid-universal/common' ;
1516import { ExcelExportService } from '@slickgrid-universal/excel-export' ;
1617import { PdfExportService } from '@slickgrid-universal/pdf-export' ;
1718import { TextExportService } from '@slickgrid-universal/text-export' ;
1819import { Slicker , type SlickVanillaGridBundle } from '@slickgrid-universal/vanilla-bundle' ;
1920import { ExampleGridOptions } from './example-grid-options' ;
21+ import { showToast } from './utilities' ;
2022import '../material-styles.scss' ;
2123import './example02.scss' ;
2224
@@ -65,6 +67,11 @@ export default class Example02 {
6567 console . log ( `sort: ${ window . performance . now ( ) - this . sortStart } ms` ) ; // use console for Cypress tests
6668 } ) ;
6769 } ) ;
70+ this . _bindingEventService . bind (
71+ gridContainerElm ,
72+ 'onformatteddatacachecompleted' ,
73+ this . handleFormattedDataCacheCompleted . bind ( this ) as EventListener
74+ ) ;
6875 this . sgb = new Slicker . GridBundle ( gridContainerElm , this . columns , { ...ExampleGridOptions , ...this . gridOptions } , this . dataset ) ;
6976
7077 // you could group by duration on page load (must be AFTER the DataView is created, so after GridBundle)
@@ -216,18 +223,8 @@ export default class Example02 {
216223 groupTotalsExcelExportOptions : {
217224 style : {
218225 alignment : { horizontal : 'center' } ,
219- font : {
220- bold : true ,
221- color : 'FF005289' ,
222- underline : 'single' ,
223- fontName : 'Consolas' ,
224- size : 10 ,
225- } ,
226- fill : {
227- type : 'pattern' ,
228- patternType : 'solid' ,
229- fgColor : 'FFE6F2F6' ,
230- } ,
226+ font : { bold : true , color : 'FF005289' , underline : 'single' , fontName : 'Consolas' , size : 10 } ,
227+ fill : { type : 'pattern' , patternType : 'solid' , fgColor : 'FFE6F2F6' } ,
231228 border : {
232229 top : { color : 'FFa500ff' , style : 'thick' } ,
233230 left : { color : 'FFa500ff' , style : 'medium' } ,
@@ -280,9 +277,13 @@ export default class Example02 {
280277 enablePdfExport : true ,
281278 enableFiltering : true ,
282279 enableGrouping : true ,
280+ enableFormattedDataCache : false , // enable it when you have a large dataset (e.g. we'll enable it when loading over 10K)
283281 columnPicker : {
284282 onColumnsChanged : ( e , args ) => console . log ( e , args ) ,
285283 } ,
284+ groupItemMetadataOption : {
285+ toggleOnNodeTitle : true , // enable toggle of group by clicking on the toggle icon or its title (not just the toggle icon)
286+ } ,
286287 enableExcelExport : true ,
287288 excelExportOptions : {
288289 filename : 'my-export' ,
@@ -298,18 +299,9 @@ export default class Example02 {
298299 customExcelHeader : ( workbook , sheet ) => {
299300 const excelFormat = workbook . getStyleSheet ( ) . createFormat ( {
300301 // every color is prefixed with FF, then regular HTML color
301- font : {
302- size : 18 ,
303- fontName : 'Calibri' ,
304- bold : true ,
305- color : 'FFFFFFFF' ,
306- } ,
302+ font : { size : 18 , fontName : 'Calibri' , bold : true , color : 'FFFFFFFF' } ,
307303 alignment : { wrapText : true , horizontal : 'center' } ,
308- fill : {
309- type : 'pattern' ,
310- patternType : 'solid' ,
311- fgColor : 'FF203764' ,
312- } ,
304+ fill : { type : 'pattern' , patternType : 'solid' , fgColor : 'FF203764' } ,
313305 } ) ;
314306 sheet . setRowInstructions ( 0 , { height : 50 } ) ; // change height of row 0
315307
@@ -370,6 +362,7 @@ export default class Example02 {
370362 } ;
371363 }
372364 if ( this . sgb ) {
365+ this . sgb . slickGrid ?. setOptions ( { enableFormattedDataCache : rowCount > 10000 } ) ;
373366 this . sgb . dataset = tmpArray ;
374367 }
375368 return tmpArray ;
@@ -388,10 +381,7 @@ export default class Example02 {
388381 }
389382
390383 exportToExcel ( ) {
391- this . excelExportService . exportToExcel ( {
392- filename : 'export' ,
393- format : 'xlsx' ,
394- } ) ;
384+ this . excelExportService . exportToExcel ( { filename : 'export' , format : 'xlsx' } ) ;
395385 }
396386
397387 exportToPdf ( ) {
@@ -412,7 +402,7 @@ export default class Example02 {
412402 this . sgb ?. slickGrid ?. invalidate ( ) ; // invalidate all rows and re-render
413403 }
414404
415- groupByDurationOrderByCount ( aggregateCollapsed ) {
405+ groupByDurationOrderByCount ( aggregateCollapsed : boolean ) {
416406 this . sgb ?. slickGrid ?. setSortColumns ( [ ] ) ;
417407 this . sgb ?. dataView ?. setGrouping ( {
418408 getter : 'duration' ,
@@ -484,4 +474,14 @@ export default class Example02 {
484474 ] as Grouping [ ] ) ;
485475 this . sgb ?. slickGrid ?. invalidate ( ) ; // invalidate all rows and re-render
486476 }
477+
478+ handleFormattedDataCacheCompleted ( e : CustomEvent < { args : OnFormattedDataCacheCompletedEventArgs } > ) {
479+ const args = e . detail . args ;
480+ showToast (
481+ `Formatted Data Cache completed: ${ args . totalRows } rows, ${ args . totalFormattedCells } cells in ${ args . durationMs } ms` ,
482+ 'info' ,
483+ 5000
484+ ) ;
485+ console . log ( 'onFormattedDataCacheCompleted' , e , args ) ;
486+ }
487487}
0 commit comments