Opened 11 years ago

Closed 10 years ago

#9058 closed defect (fixed)

Grid derefs null fields when items list in JSON is empty

Reported by: dkarr Owned by: Bryan Forbes
Priority: high Milestone: 1.4
Component: DojoX Grid Version: 1.3.0
Keywords: DataGrid Cc:
Blocked By: Blocking:

Description (last modified by bill)

I have a page with a Dialog that contains a Grid. The URL for the store for the grid varies depending on what source link spawned the request (a link in a grid row). I create the store and Grid programmatically when the source link is clicked. Some of the source links will result in a JSON object with an "items" list that is not empty. This has no problem. Some of the source links will result in a JSON object an empty "items" list. Although this should be perfectly fine, which should result in a grid showing 0 rows, it instead throws the following error:

    TypeError: this.headerContentNode.firstChild is null

I've tracked this down to the following in DataGrid.js.uncompressed.js:

    getColumnsWidth: function(){
	    return this.headerContentNode.firstChild.offsetWidth; // Integer
    }

In my test case, "this.headerContentNode.firstChild" is null, so this results in an error. There are six other locations in this file that make a similar dereference to "firstChild", which will throw an error if executed in a similar test case.

I can see that a "simple-minded" fix for this, like returning zero in a case like this, would NOT be sufficient, as the Grid still needs to have the same width that it does when it has data.

I've built a standalone test case for this, which I'll attach, but unfortunately I can't be sure it will ever demonstrate the problem, because I'm running up against a different bug, #9046. I've tried numerous variations to try to avoid this in the test case, to no avail. I'm not sure now why my original application doesn't demonstrate this other problem.

Attachments (1)

emptyItemsTest.html (2.9 KB) - added by dkarr 11 years ago.

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by dkarr

Attachment: emptyItemsTest.html added

comment:1 Changed 11 years ago by bill

Description: modified (diff)

Sounds like grid is doing sizing on creation when it should be waiting for the resize() call (if it is inside a layout container). I thought we fixed this for 1.3 but maybe not... to confirm, this is happening in 1.3 and not just 1.2?

comment:2 Changed 10 years ago by Nathan Toone

Milestone: tbd1.4
Resolution: fixed
Status: newclosed

This appears to be fixed in the trunk.

Note: See TracTickets for help on using tickets.