Jul 14, 2009, 7:25 AM
TreePanel - Drag and drop node if condition
Hi,
I have two treepanel with drag and drop enabled. I want to COPY a node from treepanel called 'TreeAllPrestation' to treepanel called 'TreePrestationBuilder' ONLY if a condition ocurrs.
The problem is that the node always is moved instead copyied and it`s dissapear from treepanel 'TreeAllPrestation'.
Why?Any ideas please?
Thanks a lot.
[AjaxMethod]
public bool TreePrestationBuilderBeforeNode(string id, string id2)
{
string targetNodeID = id;
int targetID = Convert.ToInt32(targetNodeID.Split(';')[1]);
int dropedID = Convert.ToInt32(id2);
IPrestation prestation = PrestationService.GetPrestation(dropedID);
if (prestation.PrestationType == PrestationType.Article)
{
Ext.Msg.Show(new MessageBox.Config
{
Title = "Icon Support",
Message = "You cann't bind articles",
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.WARNING,
});
return false;
}
return true;
}
function beforeDrop(dropEvent) {
Coolite.AjaxMethods.TreePrestationBuilderBeforeNode(dropEvent.target.id, dropEvent.dropNode.id, {
success: function(result) {
if (result) {
dropEvent.dropNode = new Ext.tree.TreeNode(dropEvent.dropNode.attributes);
}
return result;
}
});
}
<ext:TreePanel ID="TreePrestationBuilder" AutoScroll="true" ContainerScroll="true" Title="<%$ Resources: CreatedRates %>"
UseArrows="true" RootVisible="false" Animate="true" BufferResize="true" runat="server"
Border="false" BodyBorder="false" DDAppendOnly="true" DDGroup="PrestationBuilderGroup" DDScroll="true" Draggable="true"
EnableDD="true">
<Listeners>
<BeforeNodeDrop Fn="beforeDrop" />
</Listeners>
</ext:TreePanel>
<ext:TreePanel ID="TreeAllPrestations" AutoScroll="true" ContainerScroll="true" Title="<%$ Resources: AvailablePrestations %>"
UseArrows="true" RootVisible="false" Animate="true" BufferResize="true" runat="server"
Border="false" BodyBorder="false" CollapseFirst="true" DDGroup="PrestationBuilderGroup" EnableDrag="true" Collapsed="false">
</ext:TreePanel>
</PRE></PRE>