Project

General

Profile

Actions

Bug #862

closed

Bug:WTreeView display error in IE

Added by Anonymous almost 13 years ago. Updated almost 13 years ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
Start date:
06/18/2011
Due date:
% Done:

0%

Estimated time:

Description

in low probability

WTreeView with more than 2 columns treeview only shows the first column in IE after calling WTreeView::setRowHeaderCount(1)


Files

test1.cpp (2.63 KB) test1.cpp DQ Qin, 06/19/2011 03:33 AM
wrong_pic.png (5.98 KB) wrong_pic.png DQ Qin, 06/19/2011 03:33 AM
right_pic.png (6.72 KB) right_pic.png DQ Qin, 06/19/2011 03:33 AM
WTreeView.js (10.7 KB) WTreeView.js DQ Qin, 06/20/2011 05:12 PM
Actions #1

Updated by DQ Qin almost 13 years ago

i forgot to login before post

Updated by DQ Qin almost 13 years ago

i can provide the whole test code:

#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WWidget>
#include <Wt/WPushButton>
#include <Wt/WMessageBox>
#include <Wt/WStandardItemModel>
#include <Wt/WTreeView>
#include <Wt/WBreak>

using namespace Wt;

class TestApplication : public Wt::WApplication
{
private:
  WContainerWidget   *rootContainer_;

public:
  TestApplication(const WEnvironment& env);

  void showFirstButton();
  void showTreeView();
};

TestApplication::TestApplication(const WEnvironment& env):
  WApplication(env),
  rootContainer_(NULL)
{
  rootContainer_ = new WContainerWidget(root());
  showFirstButton();
}

void TestApplication::showFirstButton()
{
  rootContainer_->clear();

  WPushButton* firstButton = new WPushButton("show the treeview");
  firstButton->resize(WLength(200, WLength::Pixel), WLength(35, WLength::Pixel));
  firstButton->clicked().connect(this, &TestApplication::showTreeView);

  rootContainer_->addWidget(firstButton);
}

void TestApplication::showTreeView()
{
  rootContainer_->clear();

  //button
  WPushButton* secondButton = new WPushButton("close the table view");
  secondButton->resize(WLength(200, WLength::Pixel), WLength(35, WLength::Pixel));
  secondButton->clicked().connect(this, &TestApplication::showFirstButton);

  //table view
  WStandardItemModel* model = new WStandardItemModel();
  model->insertColumns(0, 4);

  model->setHeaderData(0, boost::any(std::string("column 0")));
  model->setHeaderData(1, boost::any(std::string("column 1")));
  model->setHeaderData(2, boost::any(std::string("column 2")));
  model->setHeaderData(3, boost::any(std::string("column 3")));

  model->insertRows(0, 4);
  for (int i=0; i<4; i++)
    for (int j=0; j<4; j++)
    {
      WString cellData("({1}, {2})");
      model->setData(model->index(i, j), boost::any(cellData.arg(i).arg(j))); 
    }

  WTreeView* treeView = new WTreeView();
  treeView->setModel(model);

  treeView->setColumnWidth(0, 100);
  treeView->setColumnWidth(1, 110);
  treeView->setColumnWidth(2, 120);
  treeView->setColumnWidth(3, 130);
  treeView->resize(WLength(500, WLength::Pixel), WLength(160, WLength::Pixel));

  treeView->setRowHeaderCount(1);  //!!!!

  //breaks
  WBreak* br1 = new WBreak();
  WBreak* br2 = new WBreak();

  //collect widgets
  rootContainer_->addWidget(secondButton);
  rootContainer_->addWidget(br1);
  rootContainer_->addWidget(br2);
  rootContainer_->addWidget(treeView);
}

WApplication *createApplication(const WEnvironment& env)
{
  return new TestApplication(env);
}

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

in IE8:

when u click the "show the treeview" button first time. u can see the error like attachment of wrong_pic.png.

when u click the "show the treeview" button trice. the treeview shows correctly like attachment of right_pic.png.

in FF:

it's OK

Actions #3

Updated by DQ Qin almost 13 years ago

almost 100% probability

Actions #4

Updated by DQ Qin almost 13 years ago

Perhaps i found the reason, there are some problems in WTreeView.js:

1. autoJavaScript() and adjustColumns() are all implemented with setTimerout(...), the order of calling these function is uncertain. so autoJaveScript() will be called before adjustColumns(), that is not expected, because some elments' CSS value must be set before autoJavaScript(). so we should schedule the autoJaveScript() following the first calling adjustColumns().

2. in adjustColumns(), if rowHeaderCount>0, not only width of "Wt-tv-rowc" but also width of "Wt-tv-row" should be set. otherwise, the right float divs will be hidden.

my changes is posted in attachment WTreeView.js for REFERENCE ONLY.

after i change the code and recompile WT, the error never shown.

Actions #5

Updated by Koen Deforche almost 13 years ago

  • Assignee changed from Pieter Libin to Koen Deforche
Actions #6

Updated by Koen Deforche almost 13 years ago

  • Status changed from New to InProgress
Actions #7

Updated by Koen Deforche almost 13 years ago

  • Status changed from InProgress to Resolved

Hey,

I ended with another fix (WTreeView.js is a bit of a mess as you noticed, and IE adds its own share of quirks).

Somehow the root problem is not the order in which updateColumns() or autoJavaScript() are called, but IE returns a bogus size of 0 for contentsContainer.clientWidth in this case (I am unwilling to try to understand it).

diff --git a/src/js/WTreeView.js b/src/js/WTreeView.js
index cd27df0..6754685 100644
--- a/src/js/WTreeView.js
+++ b/src/js/WTreeView.js
@@ -268,14 +268,14 @@ WT_DECLARE_WT_MEMBER
       var scrollwidth = contentsContainer.offsetWidth
         - contentsContainer.clientWidth;

-      tw -= scrollwidth;
+      if (contentsContainer.clientWidth > 0)
+       tw -= scrollwidth;

       if ($el.hasClass('column1')) {
        c0id = $el.find('.Wt-headerdiv').get(0)
          .lastChild.className.split(' ')[0];
        c0r = WT.getCssRule('#' + el.id + ' .' + c0id);
        c0w = WT.pxself(c0r, 'width');
-
       }

       // XXX: IE's incremental rendering foobars completely
Actions #8

Updated by DQ Qin almost 13 years ago

Thanks Koen.

I have some reservations about that.

In fact, I try to insert some alert(...) into both updateColumns() and autoJavaScript(),

It seems than not only in IE.

Some stange things will happen also in FF in low properbility(e.g. resize(...) for WTreeView no effect). And the occurrence of these are always with autoJavaScript() before updateColumns().

But I am willing to try your fix.

Actions #9

Updated by DQ Qin almost 13 years ago

Hey, Koen.

I have test your fix in my app.

Unfortunately, it seems more serious with setRowHeaderCount(1) and layout manager.

I haven't make it a simplified test case.

But, it really has display problems both in IE and FF.

in IE, sometimes the other column beside first completely invisible including column header.

in FF, sometimes the whole treeview's width is less than expected much.

With my fix, it works well.

Actions #10

Updated by Koen Deforche almost 13 years ago

Hey,

I do believe you but I am reluctant to include a fix for a problem which I haven't reproduced...

I've now included a change that has the effect of part of your fix --- the updateColumns() and autoJavaScript() sequencing.

Regards,

koen

Actions #11

Updated by Koen Deforche almost 13 years ago

  • Target version set to 3.1.10
Actions #12

Updated by Koen Deforche almost 13 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF