Opened 15 years ago

Closed 14 years ago

#5032 closed defect (wontfix)

Cannot change objects on the fly

Reported by: Bryan Forbes Owned by: Bryan Forbes
Priority: high Milestone: 1.1
Component: DojoX Grid Version: 1.0
Keywords: Cc:
Blocked By: Blocking:


After a has been instantiated and used by a grid, you can no longer change the underlying objects to add more properties. I'm attaching a test case which contains two grids that change the underlying objects in the model, one by using model.setData() and one by instantiating a whole new model and using grid.setModel(). Both fail.

Attachments (3)

test_grid_object_model_change.html (3.2 KB) - added by Bryan Forbes 15 years ago.
test_data_objects.js (1.4 KB) - added by Bryan Forbes 15 years ago.
Place this in grid/tests/support
test_grid_object_model.html (6.5 KB) - added by guest 14 years ago.
File to illustrate remaining problems

Download all attachments as: .zip

Change History (11)

Changed 15 years ago by Bryan Forbes

Changed 15 years ago by Bryan Forbes

Attachment: test_data_objects.js added

Place this in grid/tests/support

comment:1 Changed 15 years ago by Adam Peller


comment:2 Changed 15 years ago by Adam Peller


comment:3 Changed 14 years ago by dylan


comment:4 Changed 14 years ago by sorvell

Resolution: fixed
Status: newclosed

(In [12830]) !strict fixes #5032 To correct this problem, support was added to to allow for data structure changes. The issue here was specifically with automatic assignment of model fields. Fields are now auto-assigned when data is set and grid is notified that fields may have changed.

comment:5 Changed 14 years ago by guest

Resolution: fixed
Status: closedreopened

The solution implemented in changeset 12830 actually breaks certain scenarios that were working beforehand, and does not fix all other scenarios.

i) If the call to setModel or setData changes to a dataset with fewer rows than the existing dataset, the call throws an error "'[...]' is null or not an object". (This was working in Dojo 1.0.2, in some circumstances). This is occurring because the call to this.notify("FieldsChange") added in the allChange() method of (line 262 in model.js) forces a re-rendering of the grid after the data has been reset, but before the rowcount has been reset on the grid or scroller, and so an attempt is made to access non-existent rows.

This can be fixed by moving the call to this.notify("FieldsChange") to after the call to the parent method. The call is needed, otherwise data can appear in the wrong columns in some circumstances.

ii) If the new dataset contains different or additional fields, and is applied using setData() the new columns may not be displayed, even if present in the structure. This appears to be due to the autoAssignFields() method not clearing existing fields before processing the new ones.

This can be fixed by adding a call to this.fields.clear() before the for loop in autoAssignFields() (line 267 in model.js).

I will attach a test page which can be used to demonstrate these problems. I am not certain if either of my fixes breaks anything else, but I have not experienced any problems in my pages.

Changed 14 years ago by guest

Attachment: test_grid_object_model.html added

File to illustrate remaining problems

comment:6 Changed 14 years ago by guest

BTW, my environment is Dojo 1.1.1 in IE6.

Steps to reproduce the above problems with the attached file (after changing paths appropriately):

To get the error, leave the "Change no of data rows" checkbox checked, select "Use setModel" or "Use setData", click on "Change grid" button - 2 additional rows will be displayed. Click on the "Change grid" button again - display reduces to 2 rows, but the error is thrown (and the page will not function properly without a refresh).

To see the problem with data in an added column not being displayed, on a newly re-loaded page de-select the "Change no of data rows" checkbox, leaving the "Change no of data cols" checkbox checked. Select the "Use setData" radio button, and click on the "Change grid" button again - the grid will be re-displayed with an additional column "Supplier", empty of data. However, if you use "Use setModel", the additional data is displayed.

comment:7 Changed 14 years ago by Adam Peller

Owner: changed from sorvell to Bryan Forbes
Status: reopenednew

Bryan, can you re-assess and set the milestone appropriately? Thanks

comment:8 Changed 14 years ago by Bryan Forbes

Resolution: wontfix
Status: newclosed

Closing because doesn't exist anymore and we're not doing a 1.1.2 release.

Note: See TracTickets for help on using tickets.