@@ -484,6 +484,51 @@ class List extends Window {
484484 return findInput ;
485485 }
486486
487+ SetupPrint ( ) {
488+ if ( ! this . toolbar ) return null ;
489+
490+ const printButton = this . AddToolbarButton ( "Print" , "mono/printer.svg?light" ) ;
491+
492+ printButton . onclick = ( ) => {
493+ const newPrint = window . open ( ) ;
494+ newPrint . document . title = this . header . textContent ;
495+ newPrint . document . write ( "<html><body></body></html>" ) ;
496+
497+ const table = document . createElement ( "table" ) ;
498+ table . style . borderCollapse = "collapse" ;
499+ newPrint . document . body . appendChild ( table ) ;
500+
501+ for ( let i = 0 ; i < this . columnsElements . length ; i ++ ) {
502+ const th = document . createElement ( "th" ) ;
503+ th . style . textTransform = "uppercase" ;
504+ th . textContent = this . columnsElements [ i ] . textContent ;
505+ table . appendChild ( th ) ;
506+ }
507+
508+ for ( let i = 0 ; i < this . list . childNodes . length ; i ++ ) {
509+ const entry = this . link . data [ this . list . childNodes [ i ] . getAttribute ( "id" ) ] ;
510+
511+ const tr = document . createElement ( "tr" ) ;
512+
513+ for ( let j = 0 ; j < this . columnsElements . length ; j ++ ) {
514+ const td = document . createElement ( "td" ) ;
515+ td . style . padding = "1px 2px" ;
516+ td . style . border = "1px solid #c0c0c0" ;
517+ const key = this . columnsElements [ j ] . textContent ;
518+ if ( key in entry ) {
519+ td . textContent = entry [ key ] . v ;
520+ }
521+ tr . appendChild ( td ) ;
522+ }
523+ table . appendChild ( tr ) ;
524+ }
525+
526+ newPrint . onload = ( ) => newPrint . print ( ) ;
527+ newPrint . document . close ( ) ;
528+ setTimeout ( ( ) => newPrint . close ( ) , 99 ) ;
529+ } ;
530+ }
531+
487532 PopOut ( ) { //overrides
488533 super . PopOut ( ) ;
489534 this . UpdateViewport ( true ) ;
0 commit comments