Opened 10 years ago

Closed 7 years ago

#10500 closed defect (fixed)

DataGrid rowSelector messed up when in TabContainer

Reported by: roaming Owned by: Evan
Priority: high Milestone: 1.8
Component: DojoX Grid Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:

Description

In a simple grid placed within a ContentPane? of a TabContainer?, rowSelector appears messed up - it is shifted over and blank (see screenshot). Seen in Firefox and Safari.

Attachments (5)

row_selector.png (12.8 KB) - added by roaming 10 years ago.
screenshot
test_rowselector.html (1.7 KB) - added by roaming 10 years ago.
grid-rowselector-width-bug.jpg (5.6 KB) - added by dtynan 10 years ago.
Rowselector width bug screenshot.
grid-rowselector-good.jpg (5.1 KB) - added by dtynan 10 years ago.
What the rowselector should look like (no bug in this screenshot)
rowselector.diff.patch (1.8 KB) - added by dtynan 10 years ago.
Patch to fix the rowselector width problem.

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by roaming

Attachment: row_selector.png added

screenshot

Changed 10 years ago by roaming

Attachment: test_rowselector.html added

comment:1 Changed 10 years ago by bill

Component: GeneralDojoX Grid
Owner: changed from anonymous to Nathan Toone

Changed 10 years ago by dtynan

Rowselector width bug screenshot.

Changed 10 years ago by dtynan

Attachment: grid-rowselector-good.jpg added

What the rowselector should look like (no bug in this screenshot)

Changed 10 years ago by dtynan

Attachment: rowselector.diff.patch added

Patch to fix the rowselector width problem.

comment:2 Changed 10 years ago by dtynan

We have also run across the exact same problem in 1.4. We see the rowSelector width problem for grids inside tabContainers and inside Dialogs.

  • grid in tabContainer - problem appears in FF, Safari, Chrome, Opera
  • grid in Dialog - problem appears in FF, Chrome, Opera

I have attached 3 additional files for this problem:

  • grid-rowselector-width-bug.jpg - another example of the problem
  • grid-rowselector-good.jpg - screenshot of what it should look like
  • rowselector.diff.patch - a diff of my patch against the 1.4 release

Let me describe the problem & fix in detail, in case it's not obvious why the change is needed:

We tracked the problem down to changes made in version 1.4 to improve grid performance (can't recall the ticket#). The change in 1.4 that causes the issue is in the adaptWidth() function in _rowSelector.js in dojox/grid.

This is the code in 1.4:

adaptWidth: function(){
  // Only calculate this here - rather than every call to buildRowContent
  if(!("contentWidth" in this) && this.contentNode){
    this.contentWidth = this.contentNode.offsetWidth - this.padBorderWidth;
  }
},

The problem is that this.contentNode.offsetWidth is not accurate on the first time or two adaptWidth is called. For us, we're getting -13 (negative 13) as the value the first time through, which is causing the problem. That means this.contentWidth is then true, but with a bogus value in it.

In 1.3, my guess is that this was not an issue because this.contentNode.offsetWidth was recalculated many times, regardless of whether or not it had a value already. Indeed, if we change the 1.4 code to do that, the problem goes away. However, you're back to the performance hit of recalculating many times.

Since we really only need to calculate two or three times before it gets the right positive number for offsetWidth, we came up with this compromise:

adaptWidth: function(){
  // Only calculate this here - rather than every call to buildRowContent
  if(!("contentWidth" in this) && this.contentNode){
    if ( this.contentNode.offsetWidth > 0 ){
      this.contentWidth = this.contentNode.offsetWidth - this.padBorderWidth;
    }
  }
},

This is tested & working in our environment across several tabContainers and dialogs, with grids as small as 3 or 4 rows. So that fix, or something similar to cause it to make sure this.contentWidth ends up with a good value, is needed.

Note that I have signed the Dojo CLA.

Thanks, Dylan Tynan (dtynan@…)

comment:3 Changed 9 years ago by Nathan Toone

Owner: Nathan Toone deleted

Unassigning my tickets.

comment:4 Changed 8 years ago by evan

Milestone: tbd1.7
Owner: set to evan

comment:5 Changed 8 years ago by evan

Owner: changed from evan to Evan

comment:6 Changed 7 years ago by Evan

Resolution: fixed
Status: newclosed

In [29252]:

Fixes #10500, thanks for roaming's patch, by adding a sane check with this.contentNode.offsetWidth

Note: See TracTickets for help on using tickets.