版本信息:dgrid 1.1.0
示例站点:http ://wab-preinspection-test.s3-website-us-west-2.amazonaws.com/
问题:
将行拖到网格外,然后放到网格内时,网格会被清除。
可能的原因:
拖放css类被分配了两次。
实验室的拖放示例显示了在 dgrid-scroller 级别分配一次的 dnd 类:
<div class="dgrid-scroller dojoDndSource dojoDndTarget dojoDndContainer" style="user-select: none; margin-top: 25px; margin-bottom: 0px;">
而 dnd 类在我的代码中分配了两次:
<div id="grid" class="dgrid dgrid-grid ui-widget dojoDndTarget dojoDndContainer" role="grid">
<div class="dgrid-scroller dojoDndSource dojoDndTarget dojoDndContainer" style="user-select: none; margin-top: 34px; margin-bottom: 0px;">
代码
网格属性:
function createGrid(){
dGrid = declare([Grid,DnD,Selection,ColumnResizer])
//basic grid properties
grid = new dGrid({
bufferRows: 2000,
farOffRemoval: 600000,
keepScrollPosition: true,
minRowsPerPage: 2000,
maxRowsPerPage: 5000
},'grid');
}
源属性:
//create target for Drag and Drop events
function createTarget(){
target = new DnDSource('grid', {
accept: ['dgrid-row'],
delay: 2,
isSource: false
}
});
}
掉落事件:
//listen for drop
DnDevent = dojo.connect(target,"onDndDrop", function(){
//update grid with new order
newId = 1
array.forEach(grid.collection.data, function(item){
changedSequence[item.OBJECTID] = {"Order":newId}
item.NewSequence = newId
newId += 1
})
//reload the grid to show changes
setTimeout( function(){ grid.refresh({ keepScrollPosition: true })} ,500)