Project

General

Profile

Ext::TableView rendering when changing parent Layout Geometry

Added by Gianluca Sorrentino about 14 years ago

Hi,

i have a container with a GridLayout ( 1 row, 2 cols ):

the second contains a Widget with a GridLayout too (1 row, 1 col) where i've added an Ext::TableView (this allow the tableview to take the entire space of the parent).

All seems to work fine. The problem comes when i attempt to change the geometry of any Layout ( in example removing the 1st column of the main layout ) inserting or removing Widgets: the new geometry is rendered correctly but the tableview resizes it's viewport taking a width of about 270px or just disappears ( in this case i've found the cause: the parent widget of the ext tableview takes a heigth of 0px ).

The structure i wish to render is like a common email client:

 ________________________________________________________
|               |                                        |
|               |                                        |
| SEARCH PARAMS |              RESULTS TABLE             |
|               |                                        |
|               |________________________________________|
|               |                                        |
|               |              DATA VIEWER               |
|               |                                        |
|_______________|________________________________________|

In the starting structure the data viewer is not added to the LM. As i do it with

 rightSideWidgetLayout->addWidget(1,0, dataView); 

then the results table behavior is about undefined.

Thanks to all in advance.

Regards,

Gianluca.


Replies (4)

RE: Ext::TableView rendering when changing parent Layout Geometry - Added by Gianluca Sorrentino about 14 years ago

I've missed to say that the problems comes just if the addWidget is called after client rendering.

The structure is correctly rendered if created before been sent to the browser.

RE: Ext::TableView rendering when changing parent Layout Geometry - Added by Koen Deforche about 14 years ago

There was indeed a bug with ExtJS widgets in a standard layout manager.

The following case works now with the latest git version. Is this the scenario that you are looking for ?

#include <Wt/WApplication>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WContainerWidget>
#include <Wt/Ext/TableView>
#include <Wt/WPushButton>
#include <Wt/WGridLayout>
#include <Wt/WText>

using namespace Wt;

class TestApp : public WApplication {
public:
 TestApp( const WEnvironment& env ) :
   WApplication( env ) {

   top = new WGridLayout();
   root()->setLayout(top);

   WPushButton *button = new WPushButton("Change");
   button->clicked().connect(this, &TestApp::change);

   top->addWidget(button, 0, 0);

   WContainerWidget *w;
   top->addWidget(w = new WContainerWidget(), 0, 1);
   top->setColumnStretch(1, 1);
   top->setRowStretch(0, 1);

   WGridLayout *table = new WGridLayout();
   w->setLayout(table);

   Ext::TableView *tableView;
   table->addWidget(tableView = new Ext::TableView(), 0, 0);

   tableView->setModel(new WStandardItemModel(5, 5));
 }

 void change() {
   top->addWidget(new WText("One more here"), 0, top->columnCount());
   top->addWidget(new WText("One more there"), top->rowCount(), 0);
 }

  WGridLayout *top;
};

WApplication *createApplication(const WEnvironment& env)
{
  WApplication *app = new TestApp(env);
  return app;
}

int main(int argc, char **argv)
{
  return WRun(argc, argv, &createApplication);
}

RE: Ext::TableView rendering when changing parent Layout Geometry - Added by Gianluca Sorrentino about 14 years ago

Thanks Koen, you hit the target!

Compiling my program again with the latest wt git version the browser renders the Ext::TableView correctly even if i add something to the layout later.

Unfortunately the tableview, wich is configured with a pager, seems to reset itself on every layout change: the pager goes to the first page and so i loose the page/row selection.

Is there a way to avoid this?

Regards

RE: Ext::TableView rendering when changing parent Layout Geometry - Added by Koen Deforche about 14 years ago

Hey,

With the current implementation of the layout manager, unfortunately not: on every update, the entire layout is rerendered and thus widgets that keep client-side state (such as ExtJS) are reset. It can be fixed with some effort though, and is something we already have been discussing here.

Can you post it as a feature request ?

Regards,

koen

    (1-4/4)