PDA

View Full Version : [CLOSED] TreePanel DragDrop



bbros
Jul 31, 2022, 4:10 PM
Hi! I'm trying to port the following v5 code to v7.
I cannot find the ItemMove listener.


<ext:TreePanel
ID="TreePanel1"
runat="server"
Height="300"
Width="250"
UseArrows="true">
<Listeners>
<ItemMove Fn="moveNode" Delay="1" />
</Listeners>
<View>
<ext:TreeView runat="server">
<Plugins>
<ext:TreeViewDragDrop runat="server" ContainerScroll="true" />
</Plugins>
</ext:TreeView>
</View>
</ext:TreePanel>

this code becomes from this sample: https://examples5.ext.net/#/TreePanel/Basic/Reorder_Nodes/

could you please help me?

fabricio.murta
Aug 02, 2022, 2:21 PM
Hello @bbros!

Plugin listeners aren't always available to the component and currently Ext.NET 7 has no means to tell them apart. In that case, you'd need to wrap the listeners in customConfig blocks. Something like this:



<customConfig>
<ext-add key="listeners">
<ext-add key="itemmove">
<ext-add key="delay" value="1" />
<ext-add key="fn" value="moveNode" mode="Raw" />
</ext-add>
</ext-add>
</customConfig>


Beware if you have other <listener></listener> blocks in the same component they'll be completely overridden by the custom one. So once you add one custom listener, you'll need to move the other listeners to the CustomConfig block.

Hope this helps!

bbros
Aug 02, 2022, 3:42 PM
Thank you for the suggestion.
I'm working in codebehind, so my implementation is

tree.CustomConfig = new JsObject()
{
{ "listeners", new JsObject()
{
{ "itemmove", new JsObject()
{
{ "delay", 1 },
{ "fn", new JsObject("moveNode", ParameterMode.Raw) }
}
}
}
}
};

fabricio.murta
Aug 02, 2022, 4:37 PM
Hello @bbros!

Can you provide a test case so we can test and be able to tell what's wrong with your approach?

Looking forward to your follow-up!

bbros
Aug 04, 2022, 11:06 AM
I just want to share the codebehind-version of your suggestion; this is working fine, thanks!

Maybe I'll need help about the treepanel, because the tree doesn't allow me to drop a node over a root node; anyway I created a simple repro-project which is working; I'll do my checks and in case I've been struggling too long I'll try to ask you an help!

Thank you much, you can consider this thread as solved.

fabricio.murta
Aug 08, 2022, 8:12 PM
Oh, alright! I have misread your response. It was a bit hard to tell whether the code snippet worked or not but, if you said it works for you, well, I don't see how it couldn't! :-)

Thanks for sharing the approach that worked for you, and glad the tidbits we provided helped you find the solution!