PDA

View Full Version : [CLOSED] Raising ItemMove when reordering a node into not loaded node



RCN
Jun 19, 2012, 8:45 PM
Hi folks, i have already had some problems when reordering a node, described in the following thread: http://forums.ext.net/showthread.php?19515-CLOSED-Remove-moving-a-node-VS-loading-target%B4s-children

and after testing it better a found another issue.

Take a look in the following structure:

root 1

sub 1
sub 2
sub 3


root 2
root 3


if sub 1 is moved into root 2, which is not loaded/expanded yet, the ItemMove event is not raised.

I need that this event is raised because i need to refresh the order column, shown in my TreePanel (not in this sample).



<ext:TreePanel ID="TreePanel2" runat="server" Title="Remote Move vs Remote Load"
Height="700" Width="400" Margins="10" Border="false" Mode="Remote" RemoteMoveUrl="/Example/MoveNode">
<Store>
<ext:TreeStore ID="TreeStore1" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeChildren">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="0" Text="Root" />
</Root>
<Fields>
<ext:ModelField Name="Task" />
</Fields>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Text="Task" Flex="2" Sortable="true"
DataIndex="Task" />
</Columns>
</ColumnModel>
<View>
<ext:TreeView ID="TreeView1" runat="server" TrackOver="true">
<Plugins>
<ext:TreeViewDragDrop ID="TreeViewDragDrop1" AllowLeafDrop="true" runat="server" />
</Plugins>
</ext:TreeView>
</View>
<Listeners>
<ItemMove Handler="def()" />
</Listeners>
</ext:TreePanel>




<script type="text/javascript">
var def = function () {
alert('def');
}
</script>




public ActionResult MoveNode(string[] ids, string targetId, string point)
{
object r = new { actionSuccess = true };

return Content(JSON.Serialize(r), "json/application");
}

public StoreResult LoadFakeChildren()
{
NodeCollection nodes = new NodeCollection(false);


for (int index = 1; index < 6; index++)
{
Node no = new Node();
no.NodeID = index.ToString() + DateTime.Now.Second;
no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
nodes.Add(no);
}

return new StoreResult { Data = nodes.ToJson() };
}

Daniil
Jun 19, 2012, 9:50 PM
Hi,

Confirm, thanks for the report. We will investigate.

Vladimir
Jun 19, 2012, 10:11 PM
When you drop a node to not expanded node then real moving is not performed (if Remote mode is used).
Dropped node will be added with all children after expand (if return that node from a server, of course)

Therefore refresh anything is based on that node has no sense because the node has no children until its expanding
I suggest to call the same code (as in ItemMove) in Load event



<ItemMove Handler="def()" />
<Load Handler="def()" />

RCN
Jun 20, 2012, 2:12 AM
Take a look in the following structure:

Name -------------- Order
root 1 -------------- 1

sub 1 ------- 1
sub 2 ------- 2
sub 3 ------- 3
root 2 -------------- 2
root 3 -------------- 3


if i reorder sub 2 into root 2 it will appear like this:


Name -------------- Order
root 1 -------------- 1

sub 1 ------- 1
sub 3 ------- 3

root 2 -------------- 2
sub 2 ------- 1
root 3 -------------- 3


but i need that it appears like this


Name -------------- Order
root 1 -------------- 1

sub 1 ------- 1
sub 3 ------- 2

root 2 -------------- 2
sub 2 ------- 1
root 3 -------------- 3


it would be nice to raise ItemMove event after the load/expand process is complete.

Vladimir
Jun 20, 2012, 3:39 PM
I guess that if remote mode is used then it is better to use remote success for move action
Try to add the following listeners to a tree


<RemoteActionSuccess Handler="if(action == 'raMove'){alert('Node:'+o.node.id);}" />

RCN
Jun 20, 2012, 4:44 PM

Vladimir
Jun 20, 2012, 4:56 PM
Please update from SVN and retest,
Now ItemMove should be fired after a target node children are loaded

RCN
Jun 20, 2012, 6:02 PM

RCN
Jun 20, 2012, 6:48 PM
Thank you Vladimir, now it works fine :)

Please mark it as closed.