Hi Daniil,
I have update source in CODE block. Please check and give your feedback.Also I have attached sample image
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Coolite.Ext.Web" %>
<%@ Import Namespace="Coolite.Utilities" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<ext:ScriptContainer ID="ScriptContainer1" runat="server">
</ext:ScriptContainer>
<link rel="stylesheet" type="text/css" href="css/ext-all-embedded.css" />
<link rel="stylesheet" type="text/css" href="css/xtheme-slate.css" />
<link rel="stylesheet" type="text/css" href="css/common.css" />
<style type="text/css">
.head
{
color: Red;
}
.position
{
color: Green;
}
</style>
<script runat="server">
private class Node
{
public Node(string name)
{
this.Name = name;
}
public string Name
{
get;
set;
}
private List<ChildNode> _ChildNodes;
public List<ChildNode> ChildNodes
{
get
{
if (this._ChildNodes == null)
{
this._ChildNodes = new List<ChildNode>();
}
return this._ChildNodes;
}
}
}
private class ChildNode
{
public ChildNode()
{
}
public ChildNode(string title)
{
this.Title = title;
}
public string Title
{
get;
set;
}
public string Parent
{
get;
set;
}
}
#region Private Methods
private void BindAvailabeFields()
{
this.PlaceHolder1.Controls.Add(trp_left);
Coolite.Ext.Web.TreeNode root = new Coolite.Ext.Web.TreeNode("FIELDS");
root.Expanded = true;
root.AllowDrag = false;
trp_left.Root.Add(root);
List<Node> CHead = this.GetHead();
foreach (Node chead in CHead)
{
Coolite.Ext.Web.TreeNode TNhead = new Coolite.Ext.Web.TreeNode(chead.Name);
TNhead.AllowDrag = false;
root.Nodes.Add(TNhead);
foreach (ChildNode childnode in chead.ChildNodes)
{
Coolite.Ext.Web.TreeNode objtreenode = new Coolite.Ext.Web.TreeNode(childnode.Title);
switch (chead.Name)
{
case "HEAD":
TNhead.IconCls = "head";
objtreenode.IconCls = "head";
break;
case "POSITION":
TNhead.IconCls = "position";
objtreenode.IconCls = "position";
break;
case "DETAIL":
TNhead.IconCls = "detail";
objtreenode.IconCls = "detail";
break;
}
TNhead.Nodes.Add(objtreenode);
}
}
}
private void BindTemplateFieldsRoot()
{
Coolite.Ext.Web.TreeNode root2 = new Coolite.Ext.Web.TreeNode("FIELDS");
root2.Expanded = true;
trp_right.Root.Add(root2);
}
private List<Node> GetHead()
{
List<ChildNode> childnodelist = new List<ChildNode>();
ChildNode objchildnode = new ChildNode();
System.Data.DataView dvFilter = new System.Data.DataView();
//Assign Head Template
Node HeadNode = new Node("HEAD");
string[] arrhead = { "Order No", "Order Date", "Supplier Name" };
for (int i = 0; i < arrhead.Length; i++)
{
objchildnode = new ChildNode();
objchildnode.Title = arrhead[i];
objchildnode.Parent = "HEAD";
childnodelist.Add(objchildnode);
}
HeadNode.ChildNodes.AddRange(childnodelist);
//Assign Position Template
childnodelist = new List<ChildNode>();
Node PositionNode = new Node("POSITION");
string[] arrpos = { "Quantity", "Amount", "UOM" };
for (int i = 0; i < arrpos.Length; i++)
{
objchildnode = new ChildNode();
objchildnode.Title = arrpos[i];
objchildnode.Parent = "POSITION";
childnodelist.Add(objchildnode);
}
PositionNode.ChildNodes.AddRange(childnodelist);
return new List<Node> { HeadNode, PositionNode };
}
#endregion
#region Event Handlers
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindAvailabeFields();
BindTemplateFieldsRoot();
}
}
#endregion
</script>
<script type="text/javascript">
function clone(node, destination) {
var atts = node.attributes;
atts.id = Ext.id();
var clonedNode = new Ext.tree.TreeNode(Ext.apply({}, atts));
clonedNode.text = node.text;
for (var i = 0; i < node.childNodes.length; i++) {
clonedNode.appendChild(clone(node.childNodes[i]));
}
var flag = 1;
for (var i = 0; i < destination.root.childNodes.length; i++) {
if (destination.root.childNodes[i].text == node.text) {
flag = 0;
break;
}
}
if (flag == 1) {
return clonedNode;
}
else {
return 1;
}
}
var Title = "";
var msginvalidmove = "";
function moveNode(source, destination, copy) {
try {
var node = source.getSelectionModel().getSelectedNode();
node.id;
if (Ext.isEmpty(node)) {
top.ShowInformation('1', msginvalidmove, Title);
return;
}
var destionationRoot = destination.getRootNode();
var temp;
if (copy == true) {
temp = clone(node, destination);
if (temp != 1) {
destionationRoot.appendChild(temp);
btndis();
}
}
else {
temp = node.remove();
destionationRoot.appendChild(temp);
btndis();
}
trp_right.getRootNode().expand();
}
catch (e) {
}
}
function btndis() {
var LV_A = trp_right.getRootNode().childNodes.length;
var LV_D2 = document.getElementById('img_save');
if (LV_A != 0) {
LV_D2.disabled = false;
}
else {
LV_D2.disabled = true;
}
}
function moveall() {
removeall();
var T = trp_left.root.attributes.children;
for (var i = 0; i < T.length; i++) {
var T1 = T[i].children;
if (T1 != null || T1 != undefined) {
for (var j = 0; j < T1.length; j++) {
var atts = T1[j];
atts.id = Ext.id();
var cl = new Ext.tree.TreeNode(Ext.apply({}, atts));
cl.text = T1[j].text;
trp_right.root.appendChild(cl);
}
}
}
trp_right.getRootNode().expand();
btndis();
}
function removeall() {
var dest = trp_right.getRootNode();
for (var i = dest.childNodes.length - 1; i >= 0; i--) {
temp = dest.childNodes[i].remove();
}
btndis();
}
var X = {
add: function(source, destination) {
source = source || trp_left;
destination = destination || trp_right;
var selectedNode = source.getSelectionModel().getSelectedNode();
var destinationSelectedNode = destination.getSelectionModel().getSelectedNode();
if (selectedNode && destinationSelectedNode == null) {
if (!isNumber(selectedNode.id))
destination.getRootNode().appendChild(selectedNode);
//btnEdit.setDisabled(true);
}
else if (selectedNode && destinationSelectedNode != null) {
if (destinationSelectedNode.getDepth() == "1") {
if (!isNumber(destinationSelectedNode.id))
destinationSelectedNode.parentNode.appendChild(selectedNode);
else
destinationSelectedNode.appendChild(selectedNode);
}
else {
destinationSelectedNode.parentNode.appendChild(selectedNode);
}
destinationSelectedNode.unselect();
//btnEdit.setDisabled(true);
}
},
remove: function(source, destination) {
source = source || trp_right;
destination = destination || trp_left;
var selectedNode = source.getSelectionModel().getSelectedNode();
var objparentnode = null;
if (selectedNode.attributes.iconCls == 'head') {
objparentnode = destination.getNodeById('HEAD');
}
if (objparentnode != null) {
objparentnode.appendChild(selectedNode);
}
}
};
function isNumber(data) {
return !isNaN(data - 0);
}
</script>
<style type="text/css">
.hidd
{
visibility: hidden;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ScriptManager ID="ScriptManager1" runat="server" RenderStyles="File">
</ext:ScriptManager>
<ext:ViewPort ID="VP1" runat="server">
<Body>
<ext:BorderLayout ID="BL1" runat="server" StyleSpec="background-color:transparent;">
<Center>
<ext:Panel ID="Pnl2" runat="server" Border="false" StyleSpec="padding-left:10px;"
AutoScroll="true">
<Body>
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td>
<ext:TreePanel ID="trp_left" runat="server" AutoScroll="true" RootVisible="false"
Width="300" Height="360" AllowLeafDrop="true">
</ext:TreePanel>
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
</td>
<td>
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td>
<ext:Button ID="Btn_AddAll" runat="server" IconCls="but_last">
<Listeners>
<Click Handler="moveall();" />
</Listeners>
</ext:Button>
</td>
</tr>
<tr>
<td>
<ext:Button ID="Btn_Add" runat="server" IconCls="but_next">
<%--<Listeners>
<Click Handler="moveNode(#{trp_left}, #{trp_right}, true);" />
</Listeners>--%>
<Listeners>
<Click Handler="X.add(trp_left, trp_right);" />
</Listeners>
</ext:Button>
</td>
</tr>
<tr>
<td>
<ext:Button ID="Btn_remove" runat="server" IconCls="but_previous">
<%--<Listeners>
<Click Handler="moveNode(#{trp_right}, #{trp_left},false);" />
</Listeners>--%>
<Listeners>
<Click Handler="X.remove(trp_right,trp_left);" />
</Listeners>
</ext:Button>
</td>
</tr>
<tr>
<td>
<ext:Button ID="Btn_removeall" runat="server" IconCls="but_first">
<Listeners>
<Click Handler="removeall();" />
</Listeners>
</ext:Button>
</td>
</tr>
</table>
</td>
<td>
<ext:TreePanel ID="trp_right" runat="server" AutoScroll="true" Width="300" Height="360">
</ext:TreePanel>
</td>
</tr>
</table>
</Body>
</ext:Panel>
</Center>
</ext:BorderLayout>
</Body>
</ext:ViewPort>
</div>
</form>
</body>
</html>
Originally Posted by
Daniil
Hi,
I can't reproduce the issue. Also I'm even not sure I understand your correctly.
I see a lot of unrelated to the problem code, please remove it suing this technique:
How to reduce a sample