@@ -284,84 +284,85 @@ export
284284 render ( ) {
285285 this . el . classList . add ( 'datagrid-container' ) ;
286286
287- return this . updateRenderers ( ) . then ( ( ) => {
288- this . grid = new FeatherGrid ( ) ;
289- this . grid . baseRowSize = this . model . get ( 'base_row_size' ) ;
290- this . grid . baseColumnSize = this . model . get ( 'base_column_size' ) ;
291- this . grid . baseRowHeaderSize = this . model . get ( 'base_row_header_size' ) ;
292- this . grid . baseColumnHeaderSize = this . model . get ( 'base_column_header_size' ) ;
293- this . grid . headerVisibility = this . model . get ( 'header_visibility' ) ;
294- this . grid . dataModel = this . model . data_model ;
295- this . grid . selectionModel = this . model . selectionModel ;
296- this . grid . editable = this . model . get ( 'editable' ) ;
297- this . grid . isLightTheme = this . _isLightTheme ;
298-
299- this . grid . cellClicked . connect ( ( sender : FeatherGrid , event : FeatherGrid . ICellClickedEvent ) => {
300- if ( this . model . comm ) {
301- this . model . comm . send ( {
302- method : 'custom' ,
303- content : {
304- event_type : 'cell-click' ,
305- region : event . region ,
306- column : event . column ,
307- column_index : event . columnIndex ,
308- row : event . row ,
309- primary_key_row : event . primaryKeyRow ,
310- cell_value : event . cellValue
311- }
312- } , null ) ;
313- }
314- } ) ;
287+ this . grid = new FeatherGrid ( ) ;
288+ this . grid . baseRowSize = this . model . get ( 'base_row_size' ) ;
289+ this . grid . baseColumnSize = this . model . get ( 'base_column_size' ) ;
290+ this . grid . baseRowHeaderSize = this . model . get ( 'base_row_header_size' ) ;
291+ this . grid . baseColumnHeaderSize = this . model . get ( 'base_column_header_size' ) ;
292+ this . grid . headerVisibility = this . model . get ( 'header_visibility' ) ;
293+ this . grid . dataModel = this . model . data_model ;
294+ this . grid . selectionModel = this . model . selectionModel ;
295+ this . grid . editable = this . model . get ( 'editable' ) ;
296+ // this.default_renderer must be created after setting grid.isLightTheme
297+ // for proper color variable initialization
298+ this . grid . isLightTheme = this . _isLightTheme ;
299+
300+ this . grid . cellClicked . connect ( ( sender : FeatherGrid , event : FeatherGrid . ICellClickedEvent ) => {
301+ if ( this . model . comm ) {
302+ this . model . comm . send ( {
303+ method : 'custom' ,
304+ content : {
305+ event_type : 'cell-click' ,
306+ region : event . region ,
307+ column : event . column ,
308+ column_index : event . columnIndex ,
309+ row : event . row ,
310+ primary_key_row : event . primaryKeyRow ,
311+ cell_value : event . cellValue
312+ }
313+ } , null ) ;
314+ }
315+ } ) ;
315316
316- this . grid . columnsResized . connect ( ( sender : FeatherGrid , args : void ) : void => {
317- this . model . set ( 'column_widths' , JSONExt . deepCopy ( this . grid . columnWidths ) ) ;
318- this . model . save_changes ( ) ;
319- } ) ;
317+ this . grid . columnsResized . connect ( ( sender : FeatherGrid , args : void ) : void => {
318+ this . model . set ( 'column_widths' , JSONExt . deepCopy ( this . grid . columnWidths ) ) ;
319+ this . model . save_changes ( ) ;
320+ } ) ;
321+
322+ this . model . on ( 'data-model-changed' , ( ) => {
323+ this . grid . dataModel = this . model . data_model ;
324+ } ) ;
320325
321- this . updateGridStyle ( ) ;
322- this . updateGridRenderers ( ) ;
323-
324- this . model . on ( 'data-model-changed' , ( ) => {
325- this . grid . dataModel = this . model . data_model ;
326- } ) ;
326+ this . model . on ( 'change:base_row_size' , ( ) => {
327+ this . grid . baseRowSize = this . model . get ( 'base_row_size' ) ;
328+ } ) ;
327329
328- this . model . on ( 'change:base_row_size ' , ( ) => {
329- this . grid . baseRowSize = this . model . get ( 'base_row_size ' ) ;
330- } ) ;
330+ this . model . on ( 'change:base_column_size ' , ( ) => {
331+ this . grid . baseColumnSize = this . model . get ( 'base_column_size ' ) ;
332+ } ) ;
331333
332- this . model . on ( 'change:base_column_size ' , ( ) => {
333- this . grid . baseColumnSize = this . model . get ( 'base_column_size ' ) ;
334- } ) ;
334+ this . model . on ( 'change:column_widths ' , ( ) => {
335+ this . grid . columnWidths = this . model . get ( 'column_widths ' ) ;
336+ } ) ;
335337
336- this . model . on ( 'change:column_widths ' , ( ) => {
337- this . grid . columnWidths = this . model . get ( 'column_widths ' ) ;
338- } ) ;
338+ this . model . on ( 'change:base_row_header_size ' , ( ) => {
339+ this . grid . baseRowHeaderSize = this . model . get ( 'base_row_header_size ' ) ;
340+ } ) ;
339341
340- this . model . on ( 'change:base_row_header_size ' , ( ) => {
341- this . grid . baseRowHeaderSize = this . model . get ( 'base_row_header_size ' ) ;
342- } ) ;
342+ this . model . on ( 'change:base_column_header_size ' , ( ) => {
343+ this . grid . baseColumnHeaderSize = this . model . get ( 'base_column_header_size ' ) ;
344+ } ) ;
343345
344- this . model . on ( 'change:base_column_header_size ' , ( ) => {
345- this . grid . baseColumnHeaderSize = this . model . get ( 'base_column_header_size ' ) ;
346- } ) ;
346+ this . model . on ( 'change:header_visibility ' , ( ) => {
347+ this . grid . headerVisibility = this . model . get ( 'header_visibility ' ) ;
348+ } ) ;
347349
348- this . model . on ( 'change:header_visibility' , ( ) => {
349- this . grid . headerVisibility = this . model . get ( 'header_visibility' ) ;
350- } ) ;
350+ this . model . on_some_change ( [ 'default_renderer' , 'renderers' ] , ( ) => {
351+ this . updateRenderers ( ) . then ( this . updateGridRenderers . bind ( this ) ) ;
352+ } , this ) ;
351353
352- this . model . on_some_change ( [ 'default_renderer' , 'renderers' ] , ( ) => {
353- this . updateRenderers ( ) . then ( this . updateGridRenderers . bind ( this ) ) ;
354- } , this ) ;
354+ this . model . on ( 'selection-model-changed' , ( ) => {
355+ this . grid . selectionModel = this . model . selectionModel ;
356+ } ) ;
355357
356- this . model . on ( 'selection-model-changed ' , ( ) => {
357- this . grid . selectionModel = this . model . selectionModel ;
358- } ) ;
358+ this . model . on ( 'change:editable ' , ( ) => {
359+ this . grid . editable = this . model . get ( 'editable' ) ;
360+ } ) ;
359361
360- this . model . on ( 'change:editable' , ( ) => {
361- this . grid . editable = this . model . get ( 'editable' ) ;
362- } ) ;
362+ return this . updateRenderers ( ) . then ( ( ) => {
363+ this . updateGridStyle ( ) ;
364+ this . updateGridRenderers ( ) ;
363365
364- // @ts -ignore
365366 this . pWidget . addWidget ( this . grid ) ;
366367 } ) ;
367368 }
0 commit comments