PDA

View Full Version : [CLOSED] Some Issue with TreePanel Drag and Drop



amitpareek
May 19, 2012, 6:31 AM
Hi,
I have some issues with Tree Drag and Drop. I did not have them with v1.3. May be I am missing something here.

1) I have node.Leaf=true. And have set Allow LeafDrop=true. Despite this I am not able to drop a node on it.

2) If I have node.Leaf=false, I always see a plus sign on the left of Node even if there are no children. I have to explicitely set a expandable=false to remove the plus sign. And if I set expandable=false, even if I drop a node, it wont show the plus sign.

2) If I try to expand a node (After Drop, or if it has children), it throws an error, as its expecting some event on server. In earlier versions, it would never fire a server event until explicitly mentioned. Now it always shows a loading icon (1st time when a node is expanded). Notice this in the example here : http://examples1.ext.net/#/TreePanel/Basic/Reorder_Nodes/

Expand any node, or Drop ay node on another. It will show a Loader 1st. I dont want that behaviour. I want to handle all events myself. How do I disable these default events?

Here's my code:

ASPX


<ext:ResourceManager runat="server"></ext:ResourceManager>
<ext:TreePanel ID="sectionsTree" runat="server" RootVisible="false" Width="700" Height="800" AllowLeafDrop="true">
<View>
<ext:TreeView ID="TreeView1" runat="server" MultiSelect="true" >
<Plugins>
<ext:TreeViewDragDrop ID="TreeViewDragDrop1" runat="server" />
</Plugins>
</ext:TreeView>
</View>
</ext:TreePanel>



c#


public partial class mapsections : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest) {
LoadTree(sectionsTree.Root);
}
}


public Ext.Net.NodeCollection LoadTree(Ext.Net.NodeCollection nodes)
{
if (nodes == null)
{
nodes = new Ext.Net.NodeCollection();
}


xmlStoreDbEntities db = new xmlStoreDbEntities();
Ext.Net.Node root = new Ext.Net.Node();
root.NodeID = "root";
root.Text = "No Sections Available";
root.Icon = Ext.Net.Icon.Blank;
nodes.Add(root);

for (int i = 0; i<100 ;i++)
{
Node n = new Node();
n.Text = "Node - " + i.ToString();
n.NodeID = i.ToString();
n.Leaf = true;
n.AllowDrop = true;
n.AllowDrag = true;
root.Children.Add(n);
//if (n.Children.Count == 0)
//{
// n.Expandable = false;
//}


}


return nodes;


}


}

Vladimir
May 19, 2012, 8:01 AM
I have node.Leaf=true. And have set Allow LeafDrop=true. Despite this I am not able to drop a node on it.

AllowLeafDrop must be set for TreeViewDragDrop



If I have node.Leaf=false, I always see a plus sign on the left of Node even if there are no children. I have to explicitely set a expandable=false to remove the plus sign. And if I set expandable=false, even if I drop a node, it wont show the plus sign.

All nodes is async in v2. Therefore if node is not leaf and children is not defined then the node will request nodes from a server
You can set EmptyChildren for the node to render empty children array (it will remove plus sign and prevent request to tyhe server)



If I try to expand a node (After Drop, or if it has children), it throws an error, as its expecting some event on server. In earlier versions, it would never fire a server event until explicitly mentioned. Now it always shows a loading icon (1st time when a node is expanded). Notice this in the example here : http://examples1.ext.net/#/TreePanel...Reorder_Nodes/ (http://examples1.ext.net/#/TreePanel/Basic/Reorder_Nodes/)

EmptyChildren will help you

amitpareek
May 19, 2012, 8:28 AM
Hi Vlad,
It works now. Thanks!

Don't you think this behaviour should be by default? Like EmptyChildren should be automatically true if there is no children and emptychildren should automatically change to false when a node is added?

amitpareek
May 19, 2012, 8:31 AM
One more minor issue.
MultiSelect on TreeView does'nt work. I have add a SelectionModel to enable multi select.

Vladimir
May 19, 2012, 9:36 AM
MultiSelect on TreeView does'nt work. I have add a SelectionModel to enable multi select.

MultiSelect of TreeView is initialized by MultiSelect of TreePanel. So, you have to set MultiSelect for TreePanel



Don't you think this behaviour should be by default? Like EmptyChildren should be automatically true if there is no children and emptychildren should automatically change to false when a node is added?

I don't think so. In mostly cases, empty non leaf node means that children will be loaded from the server after expand