Closed AlexArcPy closed 6 years ago
This is basically a works-as-designed situation. The DnD extension only works with an unsorted store. The DnD extension manipulates the rows by removing and inserting items in the store. With sorting is applied, the store will always return the items to the grid in the order determined by the sorting.
One idea that might help... Create a memory store that does not track the sorting but always rearranges the items in the store's data array. Here is an example:
define([
'dojo/_base/declare',
'dojo/when',
'dstore/Memory'
], function (declare, when, Memory) {
/**
* A memory store that does not create a query log. Items are always fetched in the order they
* exist in the data array. When this store is sorted, the data items are always rearranged in the data array.
*/
return declare([Memory], {
sort: function () {
var sorterStore = (new Memory({ data: this.data })).sort.apply(sorterStore, arguments);
this.setData(sorterStore.fetchSync());
return this;
}
});
});
This store will allow you to click on a grid heading, sort the rows and then use drag and drop to reorder the rows. One problem that remains is the grid heading will contains an arrow that indicates the sorting direction. After dragging and dropping a row, that arrow will no longer be a correct indication of the sortings.
An issue which seems to be easy to reproduce.
This behavior is seen in my own applications using
dgrid
. Tested on latest Chrome, Firefox and IE.This is the code I've copied from the dgrid laboratory just after adding DnD support: