Discussion:
[Wt-interest] Issue with TableView and Responsive
Mark@Lorimark Solutions
2015-09-08 21:12:29 UTC
Permalink
We are trying to make the WTableView responsive. Right now the
right-side of the table view appears to be responsive as it pertains to
the width of the browser. But, the bottom of the Table is not. Is is
only setting its size either fixed, according to what we set it to in
code, or in Auto it takes up the amount of space required to display all
of the table data.

How can we make the bottom of the WTableView also responsive to the
parent container? (note the comment on line 514)
478 Wt::WContainerWidget *container = new Wt::WContainerWidget;·
479 ·
480 Wt::WVBoxLayout * layout = new Wt::WVBoxLayout( container );·
481 ·
482 Wt::Dbo::Transaction t(*dboSession);·
485 Wt::Dbo::Query< Wt::Dbo::ptr<MKT::Referrer> > query;·
486 query = dboSession-> find<MKT::Referrer>(); // .limit(100);·
487 ·
491 modelReferrer = new Wt::Dbo::QueryModel< Wt::Dbo::ptr<MKT::Referrer> >();·
492 modelReferrer-> setQuery( query );·
493 ·
494 modelReferrer-> addColumn( "id" );·
495 modelReferrer-> addColumn( SYS::KeyField );·
496 modelReferrer-> addColumn( MKT::Referrer::AbbreviationField );·
504 ·
505 layout-> addWidget( new Wt::WText(title) );·
506 ·
507 tableViewReferrer = new Wt::WTableView();·
508 tableViewReferrer-> setSelectionMode( Wt::SingleSelection );·
509 tableViewReferrer-> setModel( modelReferrer );·
510 ·
511 tableViewReferrer-> setMargin( Wt::WLength::Auto, Wt::Left | Wt::Right );·
512 tableViewReferrer-> setColumnResizeEnabled( true );·
513 tableViewReferrer-> setAlternatingRowColors( true );·
514 tableViewReferrer-> setHeight( 400 );· <-------------this sets the TableViewHeight fixed
515 · we want the height responsive
516 layout-> addWidget( tableViewReferrer );·
517 ·
518 return container;·
519 }·
~mark


------------------------------------------------------------------------------
Koen Deforche
2015-09-09 07:11:42 UTC
Permalink
Hey Mark,

If you want widgets to respond to the height of the browser window,
then you need to have a complete chain of layout managers from the
root() of your application down to the widget that you want to respond
to it.

It's not sufficient to wrap that widget itself in a layout manager
since, the parent itself also needs to respond, etc... up to the
root(). Only a layout manager in the root will respond to height
changes of the window itself.

Koen
We are trying to make the WTableView responsive. Right now the right-side
of the table view appears to be responsive as it pertains to the width of
the browser. But, the bottom of the Table is not. Is is only setting its
size either fixed, according to what we set it to in code, or in Auto it
takes up the amount of space required to display all of the table data.
How can we make the bottom of the WTableView also responsive to the parent
container? (note the comment on line 514)
478 Wt::WContainerWidget *container = new Wt::WContainerWidget;·
479 ·
480 Wt::WVBoxLayout * layout = new Wt::WVBoxLayout( container );·
481 ·
482 Wt::Dbo::Transaction t(*dboSession);·
485 Wt::Dbo::Query< Wt::Dbo::ptr<MKT::Referrer> > query;·
486 query = dboSession-> find<MKT::Referrer>(); // .limit(100);·
487 ·
491 modelReferrer = new Wt::Dbo::QueryModel< Wt::Dbo::ptr<MKT::Referrer>
();·
492 modelReferrer-> setQuery( query );·
493 ·
494 modelReferrer-> addColumn( "id" );·
495 modelReferrer-> addColumn( SYS::KeyField );·
496 modelReferrer-> addColumn( MKT::Referrer::AbbreviationField );·
504 ·
505 layout-> addWidget( new Wt::WText(title) );·
506 ·
507 tableViewReferrer = new Wt::WTableView();·
508 tableViewReferrer-> setSelectionMode( Wt::SingleSelection );·
509 tableViewReferrer-> setModel( modelReferrer );·
510 ·
511 tableViewReferrer-> setMargin( Wt::WLength::Auto, Wt::Left | Wt::Right );·
512 tableViewReferrer-> setColumnResizeEnabled( true );·
513 tableViewReferrer-> setAlternatingRowColors( true );·
514 tableViewReferrer-> setHeight( 400 );· <-------------this sets the
TableViewHeight fixed
515 · we want the height responsive
516 layout-> addWidget( tableViewReferrer );·
517 ·
518 return container;·
519 }·
~mark
Loading...