@@ -36,8 +36,8 @@ class QgridModel extends widgets.DOMWidgetModel {
3636 _view_name : 'QgridView' ,
3737 _model_module : 'qgrid' ,
3838 _view_module : 'qgrid' ,
39- _model_module_version : '^1.1.0 ' ,
40- _view_module_version : '^1.1.0 ' ,
39+ _model_module_version : '^1.1.1 ' ,
40+ _view_module_version : '^1.1.1 ' ,
4141 _df_json : '' ,
4242 _columns : { }
4343 } ) ;
@@ -62,16 +62,21 @@ class QgridView extends widgets.DOMWidgetView {
6262 if ( ! this . $el . hasClass ( 'q-grid-container' ) ) {
6363 this . $el . addClass ( 'q-grid-container' ) ;
6464 }
65-
66- if ( this . model . get ( 'show_toolbar' ) ) {
67- this . initialize_toolbar ( ) ;
68- }
69-
65+ this . initialize_toolbar ( ) ;
7066 this . initialize_slick_grid ( ) ;
7167 }
7268
7369 initialize_toolbar ( ) {
74- this . $el . addClass ( 'show-toolbar' ) ;
70+ if ( ! this . model . get ( 'show_toolbar' ) ) {
71+ this . $el . removeClass ( 'show-toolbar' ) ;
72+ } else {
73+ this . $el . addClass ( 'show-toolbar' ) ;
74+ }
75+
76+ if ( this . toolbar ) {
77+ return ;
78+ }
79+
7580 this . toolbar = $ ( "<div class='q-grid-toolbar'>" ) . appendTo ( this . $el ) ;
7681
7782 let append_btn = ( btn_info ) => {
@@ -196,7 +201,10 @@ class QgridView extends widgets.DOMWidgetView {
196201 * type of data in the columns of the DataFrame provided by the user.
197202 */
198203 initialize_slick_grid ( ) {
199- this . grid_elem = $ ( "<div class='q-grid'>" ) . appendTo ( this . $el ) ;
204+
205+ if ( ! this . grid_elem ) {
206+ this . grid_elem = $ ( "<div class='q-grid'>" ) . appendTo ( this . $el ) ;
207+ }
200208
201209 // create the table
202210 var df_json = JSON . parse ( this . model . get ( '_df_json' ) ) ;
@@ -391,6 +399,7 @@ class QgridView extends widgets.DOMWidgetView {
391399 this . columns ,
392400 this . grid_options
393401 ) ;
402+ this . grid_elem . data ( 'slickgrid' , this . slick_grid ) ;
394403
395404 if ( this . grid_options . forceFitColumns ) {
396405 this . grid_elem . addClass ( 'force-fit-columns' ) ;
@@ -414,6 +423,8 @@ class QgridView extends widgets.DOMWidgetView {
414423 this . slick_grid . setSelectionModel ( new Slick . RowSelectionModel ( ) ) ;
415424 this . slick_grid . setCellCssStyles ( "grouping" , this . row_styles ) ;
416425 this . slick_grid . render ( ) ;
426+
427+ this . update_size ( ) ;
417428
418429 var render_header_cell = ( e , args ) => {
419430 var cur_filter = this . filters [ args . column . id ] ;
@@ -664,7 +675,7 @@ class QgridView extends widgets.DOMWidgetView {
664675 */
665676 handle_msg ( msg ) {
666677 if ( msg . type === 'draw_table' ) {
667- this . initialize_qgrid ( ) ;
678+ this . initialize_slick_grid ( ) ;
668679 } else if ( msg . type == 'show_error' ) {
669680 alert ( msg . error_msg ) ;
670681 if ( msg . triggered_by == 'add_row' ||
@@ -773,6 +784,8 @@ class QgridView extends widgets.DOMWidgetView {
773784 this . slick_grid . scrollRowIntoView ( msg . rows [ 0 ] ) ;
774785 }
775786 this . ignore_selection_changed = false ;
787+ } else if ( msg . type == 'change_show_toolbar' ) {
788+ this . initialize_toolbar ( ) ;
776789 } else if ( msg . col_info ) {
777790 var filter = this . filters [ msg . col_info . name ] ;
778791 filter . handle_msg ( msg ) ;
0 commit comments