PDA

View Full Version : DD in TreeGrid (allowContainerDrop error)



GeX
19 Feb 2010, 12:17 PM
Hello. This error appeared when i have added this construction:

dropConfig:{ allowContainerDrop: true},
into an example's code: (http://www.extjs.com/deploy/dev/examples/treegrid/treegrid.html)

var tree = new Ext.ux.tree.TreeGrid({
title: 'Core Team Projects',
width: 500,
height: 300,
renderTo: Ext.getBody(),
enableDD: true,

dropConfig:{

allowContainerDrop: true
},

columns:[{
header: 'Task',
dataIndex: 'task',
width: 230
},{
header: 'Duration',
width: 100,
dataIndex: 'duration',
align: 'center',
sortType: 'asFloat',
tpl: new Ext.XTemplate('{duration:this.formatHours}', {
formatHours: function(v) {
if(v < 1) {
return Math.round(v * 60) + ' mins';
} else if (Math.floor(v) !== v) {
var min = v - Math.floor(v);
return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
} else {
return v + ' hour' + (v === 1 ? '' : 's');
}
}
})
},{
header: 'Assigned To',
width: 150,
dataIndex: 'user'
}],

dataUrl: 'treegrid-data.json'
});

If i taking a node and putting it between two existing nodes it goes to the bottom of the tree branch, or staing in it's place.

I found, that in this case ajax working correctly.

tree.on("beforemovenode", function(tree, node, oldParent, newParent, index) {
Ext.Ajax.request({
url: "test.php",
params: {
nodeid: node.id,
newparentid: newParent.id,
oldparentid: oldParent.id,
dropindex: index
}
});
});
And data that goes to the script is correct. I can not understand why tree doesn't save tree state in this case.

I see 2 ways to solve this problem:
1. Find the bug (if it exist)
2. Automatically reload data every drop, but i don't know how to do this.

A there any ideas?