After an afternoon of playing around on fiddle, I finally came up with a solution that works. Here's a snippet of the code that moves each selected row up one row:
01.
/* move up */
02.
$(
"#moveItemUp"
).on(
"click"
,
function
(idx, elem) {
03.
04.
var
firstItemSelected =
false
;
05.
06.
selected = visibleGrid.select();
07.
selectedIndexes = [];
08.
09.
if
(selected.length > 0) {
10.
11.
/* capture the indexes of those that are selected */
12.
$.each(selected,
function
(idx, elem) {
13.
14.
var
dataItem = visibleGrid.dataItem($(
this
));
15.
var
index = visibleGrid.dataSource.indexOf(dataItem);
16.
17.
if
(index == 0) {
18.
firstItemSelected =
true
;
19.
}
20.
21.
selectedIndexes.push(index);
22.
});
23.
24.
/* if they've selected the first item, don't let them do anything */
25.
if
(firstItemSelected ==
true
) {
26.
return
;
27.
}
28.
29.
/* move each item to the new location - one row higher than the old row */
30.
for
(i = 0; i < selectedIndexes.length; i++) {
31.
var
oldIndex = selectedIndexes[i];
32.
var
newIndex = oldIndex - 1;
33.
34.
moveDataItem(oldIndex, newIndex);
35.
}
36.
}
37.
});
38.
39.
/* used by each of the up/down buttons to move the selected items */
40.
function
moveDataItem(oldIndex, newIndex){
41.
var
dataItem = visibleGrid.dataSource.at(oldIndex);
42.
43.
visibleGrid.dataSource.remove(dataItem);
44.
visibleGrid.dataSource.insert(newIndex, dataItem);
45.
}
The project on fiddle has been updated in case you want to take a look, but that being said, if you have other suggestions on how to better accomplish this, I'm all ears!