@@ -20,6 +20,8 @@ import { Transform } from './core/transform';
2020import { Theme } from './utils' ;
2121import { KeyHandler } from './keyhandler' ;
2222
23+ import { DataGridModel as BackBoneModel } from './datagrid' ;
24+
2325import '@lumino/default-theme/style/datagrid.css' ;
2426import '../style/feathergrid.css' ;
2527
@@ -518,39 +520,16 @@ export class FeatherGrid extends Widget {
518520 this . updateGridStyle ( ) ;
519521 this . _updateGridRenderers ( ) ;
520522 this . _updateColumnWidths ( ) ;
523+ this . setGridStyle ( ) ;
521524 }
522525
523- public updateGridStyle ( ) {
524- this . _updateHeaderRenderer ( ) ;
525-
526- if ( ! this . _defaultRendererSet ) {
527- this . _defaultRenderer = new TextRenderer ( {
528- font : '12px sans-serif' ,
529- textColor : Theme . getFontColor ( ) ,
530- backgroundColor : Theme . getBackgroundColor ( ) ,
531- horizontalAlignment : 'left' ,
532- verticalAlignment : 'center' ,
533- } ) ;
526+ public setGridStyle ( ) {
527+ // Resetting grid style if theme changes.
528+ if ( this . backboneModel ) {
529+ this . grid . style = this . backboneModel . get ( 'grid_style' ) ;
534530 }
535531
536- this . _rowHeaderRenderer = new TextRenderer ( {
537- textColor : Theme . getFontColor ( 1 ) ,
538- backgroundColor : Theme . getBackgroundColor ( 2 ) ,
539- horizontalAlignment : 'center' ,
540- verticalAlignment : 'center' ,
541- } ) ;
542-
543- this . _columnHeaderRenderer = new HeaderRenderer ( {
544- textOptions : {
545- textColor : Theme . getFontColor ( 1 ) ,
546- backgroundColor : Theme . getBackgroundColor ( 2 ) ,
547- horizontalAlignment : 'left' ,
548- verticalAlignment : 'center' ,
549- } ,
550- isLightTheme : this . _isLightTheme ,
551- grid : this . grid ,
552- } ) ;
553-
532+ // Setting up theme.
554533 const scrollShadow = {
555534 size : 4 ,
556535 color1 : Theme . getBorderColor ( 1 , 1.0 ) ,
@@ -592,6 +571,40 @@ export class FeatherGrid extends Widget {
592571 } ;
593572 }
594573
574+ public updateGridStyle ( ) {
575+ this . _updateHeaderRenderer ( ) ;
576+
577+ if ( ! this . _defaultRendererSet ) {
578+ this . _defaultRenderer = new TextRenderer ( {
579+ font : '12px sans-serif' ,
580+ textColor : Theme . getFontColor ( ) ,
581+ backgroundColor : Theme . getBackgroundColor ( ) ,
582+ horizontalAlignment : 'left' ,
583+ verticalAlignment : 'center' ,
584+ } ) ;
585+ }
586+
587+ this . _rowHeaderRenderer = new TextRenderer ( {
588+ textColor : Theme . getFontColor ( 1 ) ,
589+ backgroundColor : Theme . getBackgroundColor ( 2 ) ,
590+ horizontalAlignment : 'center' ,
591+ verticalAlignment : 'center' ,
592+ } ) ;
593+
594+ this . _columnHeaderRenderer = new HeaderRenderer ( {
595+ textOptions : {
596+ textColor : Theme . getFontColor ( 1 ) ,
597+ backgroundColor : Theme . getBackgroundColor ( 2 ) ,
598+ horizontalAlignment : 'left' ,
599+ verticalAlignment : 'center' ,
600+ } ,
601+ isLightTheme : this . _isLightTheme ,
602+ grid : this . grid ,
603+ } ) ;
604+
605+ this . setGridStyle ( ) ;
606+ }
607+
595608 copyToClipboard ( ) : void {
596609 const grid = < DataGrid > ( < unknown > this ) ;
597610 // Fetch the data model.
@@ -1014,6 +1027,7 @@ export class FeatherGrid extends Widget {
10141027 private _cellClicked = new Signal < this, FeatherGrid . ICellClickedEvent > ( this ) ;
10151028 private _columnsResized = new Signal < this, void > ( this ) ;
10161029 private _isLightTheme = true ;
1030+ backboneModel : BackBoneModel ;
10171031}
10181032
10191033/**
0 commit comments