Project

General

Profile

Bug #3027

Problems with scrolling and row selecting in WTableView

Added by Alan Finley about 8 years ago. Updated about 8 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Target version:
-
Start date:
04/29/2014
Due date:
% Done:

0%

Estimated time:

Description

Several months ago I reported a bug with scrolling a WTableView to the last added row. I've recently updated to Wt 3.3.2 and still have problems with it.

Here's my example:

void addRowAndScroll(Wt::WTableView *view, Wt::WPushButton *btn)
{
    Wt::WStandardItemModel *model = dynamic_cast<Wt::WStandardItemModel*>(view->model());

    int row = model->rowCount() + 1;

    model->appendRow(new Wt::WStandardItem(Wt::WString("row#{1}").arg(row)));

    btn->setText(Wt::WString("count#{1}").arg(row));

    Wt::WModelIndex index = model->index(model->rowCount() - 1, 0);

    view->scrollTo(index);
    view->select(index);
}

Wt::WApplication* createApplication(const Wt::WEnvironment& env)
{
    Wt::WApplication *app = new Wt::WApplication(env);
    app->setTheme(new Wt::WBootstrapTheme);

    Wt::WTableView *view = new Wt::WTableView;
    view->setSelectionBehavior(Wt::SelectRows);
    view->setSelectionMode(Wt::SingleSelection);
    view->resize(200, 300);

    Wt::WStandardItemModel *model = new Wt::WStandardItemModel(view);
    view->setModel(model);

    Wt::WPushButton *btn = new Wt::WPushButton("add", app->root());
    btn->clicked().connect(boost::bind(&addRowAndScroll, view, btn));

    app->root()->addWidget(btn);
    app->root()->addWidget(view);

    return app;
}

In WBootstrapTheme scrolling still doesn't work. Also it seems that rows do not fit inside the table: if I add about 20 rows the last row is not visible. Row selection doesn't work too: I click on a row and another becomes highlighted. The more rows I add, the more distance between clicked and highlighted rows is.

In standard theme selection works fine, but scrolling still doesn't. In my example the table scrolls properly only if the last row number is odd.

Also available in: Atom PDF