@@ -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' ) ) ;
@@ -414,6 +422,8 @@ class QgridView extends widgets.DOMWidgetView {
414422 this . slick_grid . setSelectionModel ( new Slick . RowSelectionModel ( ) ) ;
415423 this . slick_grid . setCellCssStyles ( "grouping" , this . row_styles ) ;
416424 this . slick_grid . render ( ) ;
425+
426+ this . update_size ( ) ;
417427
418428 var render_header_cell = ( e , args ) => {
419429 var cur_filter = this . filters [ args . column . id ] ;
@@ -664,7 +674,7 @@ class QgridView extends widgets.DOMWidgetView {
664674 */
665675 handle_msg ( msg ) {
666676 if ( msg . type === 'draw_table' ) {
667- this . initialize_qgrid ( ) ;
677+ this . initialize_slick_grid ( ) ;
668678 } else if ( msg . type == 'show_error' ) {
669679 alert ( msg . error_msg ) ;
670680 if ( msg . triggered_by == 'add_row' ||
@@ -773,6 +783,8 @@ class QgridView extends widgets.DOMWidgetView {
773783 this . slick_grid . scrollRowIntoView ( msg . rows [ 0 ] ) ;
774784 }
775785 this . ignore_selection_changed = false ;
786+ } else if ( msg . type == 'change_show_toolbar' ) {
787+ this . initialize_toolbar ( ) ;
776788 } else if ( msg . col_info ) {
777789 var filter = this . filters [ msg . col_info . name ] ;
778790 filter . handle_msg ( msg ) ;
0 commit comments