版本信息:dgrid 1.1.0
示例网站:http://wab-preinspection-test.s3-website-us-west-2.amazonaws.com/
问题:
将行拖动到网格外部,然后在网格中删除时,网格将被清除。
可能的原因:
拖放css类被分配两次。
laboratory中的拖放示例显示了在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)