Ticket #5275 (closed defect: fixed)
Grid: ItemFileWriteStore, after sorting, edit data in table changes incorrect table row data
| Reported by: | guest | Owned by: | sorvell |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | DojoX Grid | Version: | 1.0 |
| Severity: | normal | Keywords: | grid itemfilewritestore sort |
| Cc: | frank.fortson@… |
Description
In a Grid, using ItemFileReadStore?, after sorting, if you use an editor in a cell to change the value of the cell's "data", the grid.model.data[i]."field" is changed appropriately, where i = the table row index and the grid.model.data index. No change is made to grid.model.store, appropriately.
However, in a Grid, using ItemFileWriteStore?, after sorting, if you use an editor in a cell to change the value of the cell's "data", the grid.model.data[i]."field" is changed correctly, but also an additional grid.model.data[j]."field" may be changed "incorrectly", while the grid.model.store 'i'th or 'j'th value is changed, where i = the grid.model.store index. The grid.model.store index is not correct for the grid.model.data when the table has been sorted, nor is the grid.model.data index correct for the grid.model.store, when the table has been sorted.
The grid.model.store data is always stored in the same order as when it was initially loaded. Its indices are never re-ordered.
The grid.model.data data is "re-indexed" (to match the visible row order) whenever the grid is sorted. Its indices can never be assumed to correspond to the grid.model.store indices.
So, it is incorrect to assume, in the ItemFileWriteStore? case, that a change in the grid.model.data (visible row data)'s index will point to the same row in grid.model.store. It may not.
See attached file, adapted from the dojox/grid/tests/test_tundra_edit.html file.
Using the Read store in the left Grid and clicking on a checkbox, only that checkbox is "checked", both before sorting and after sorting (by clicking on the "i" column header).
Using the Write store in the right Grid and clicking on a checkbox correctly checks a single checkbox, before sorting, but after sorting (by clicking on the "i" column header), clicking the "6" or "1" checkbox will check BOTH associated checkboxes. The grid.model.data indices 1 and 6 get set true. The grid.model.store index 1 or 6 is set true and the other is set false.
I believe it is just a problem of not translating the clicked grid.model.data index into the correct grid.model.store index.