Ticket #5032 (closed defect: wontfix)

Opened 13 months ago

Last modified 5 months ago

Cannot change dojox.grid.data.Objects objects on the fly

Reported by: BryanForbes Owned by: BryanForbes
Priority: high Milestone: 1.1
Component: DojoX Grid Version: 1.0
Severity: critical Keywords:
Cc:

Description

After a dojox.grid.data.Objects 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

test_grid_object_model_change.html (3.2 kB) - added by BryanForbes 13 months ago.
test_data_objects.js (1.4 kB) - added by BryanForbes 13 months ago.
Place this in grid/tests/support
test_grid_object_model.html (6.5 kB) - added by guest 6 months ago.
File to illustrate remaining problems

Change History

Changed 13 months ago by BryanForbes

Changed 13 months ago by BryanForbes

Place this in grid/tests/support

Changed 12 months ago by peller

  • milestone changed from 1.0.1 to 1.0.2

Changed 12 months ago by peller

  • milestone changed from 1.0.2 to 1.0.3

Changed 9 months ago by dylan

  • milestone changed from 1.0.3 to 1.1

Changed 9 months ago by sorvell

  • status changed from new to closed
  • resolution set to fixed

(In [12830]) !strict fixes #5032 To correct this problem, support was added to dojox.grid.data.Objects 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.

Changed 6 months ago by guest

  • status changed from closed to reopened
  • resolution deleted

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 "'this.data...' 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 dojox.grid.data.Objects (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 6 months ago by guest

File to illustrate remaining problems

Changed 6 months 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.

Changed 6 months ago by peller

  • owner changed from sorvell to BryanForbes
  • status changed from reopened to new

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

Changed 5 months ago by BryanForbes

  • status changed from new to closed
  • resolution set to wontfix

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

Note: See TracTickets for help on using tickets.