protected override void OnInit(EventArgs e)
        {
            this._selectedIds = (List <int>) this.Context.Cache["_selectedIds"];
            if (this._selectedIds == null)
            {
                this._selectedIds = new List <int>();
                this.Context.Cache["_selectedIds"] = this._selectedIds;
            }
            this.Layout = "hbox";
            HBoxLayoutConfig item = new HBoxLayoutConfig
            {
                Align          = HBoxAlign.Middle,
                DefaultMargins = "0"
            };

            this.LayoutConfig.Add(item);
            this._treePanelLeft    = new TreePanel();
            this._treePanelLeft.ID = "_treePanelLeft";
            this._treePanelLeft.DirectEvents.ItemDblClick.Event += new ComponentDirectEvent.DirectEventHandler(this.LeftItemDblClick_Event);
            this._treePanelLeft.Submit += new TreePanel.SubmitEventHandler(this._treePanelLeft_Submit);
            this._treePanelLeft.DirectEvents.Submit.EventMask.Set("正在添加");
            this._treePanelLeft.Title  = "可添加";
            _treePanelLeft.MultiSelect = EnableBatchAdd;
            this._treePanelLeft.Height = this.Height;
            double width = (this.Width.Value - 75.0) / 2.0;

            this._treePanelLeft.Width     = new Unit(width);
            this._treeStoreLeft           = new TreeStore();
            this._treeStoreLeft.ReadData += new TreeStoreBase.ReadDataEventHandler(this._treeStoreLeft_ReadData);
            this._treeModelLeft           = new Model();
            this.InitTreePanel(this._treePanelLeft, this._treeStoreLeft, this._treeModelLeft);
            Ext.Net.Panel component = new Ext.Net.Panel
            {
                Width       = 75,
                ButtonAlign = Alignment.Center,
                Layout      = "vbox"
            };
            if (!Ext.Net.X.IsAjaxRequest)
            {
                component.Border = false;
            }
            var buttons = new List <Ext.Net.Button>();

            if (EnableBatchAdd)
            {
                Ext.Net.Button button = new Ext.Net.Button
                {
                    Text      = "全部添加 >>",
                    TextAlign = ButtonTextAlign.Center
                };
                button.Listeners.Click.Handler = "#{" + this._treePanelLeft.ID + "}.submitNodes();";
                button.DirectEvents.Click.EventMask.Set("正在添加");
                buttons.Add(button);
            }
            Ext.Net.Button button2 = new Ext.Net.Button
            {
                Text      = "添  加 > ",
                TextAlign = ButtonTextAlign.Center
            };
            buttons.Add(button2);
            button2.DirectClick += new ComponentDirectEvent.DirectEventHandler(this.btnAddSelected_DirectClick);
            button2.DirectEvents.Click.EventMask.Set("正在添加");
            this._treePanelRight       = new TreePanel();
            this._treePanelRight.ID    = "_treePanelRight";
            this._treePanelRight.Title = "已添加";
            this._treePanelRight.DirectEvents.Submit.EventMask.Set("正在移除");
            this._treePanelRight.Submit += new TreePanel.SubmitEventHandler(this._treePanelRight_Submit);
            _treePanelRight.MultiSelect  = EnableBatchRemove;
            this._treePanelRight.Height  = this.Height;
            this._treePanelRight.DirectEvents.ItemDblClick.Event += new ComponentDirectEvent.DirectEventHandler(this.RightItemDblClick_Event);
            this._treePanelRight.Width     = new Unit(width);
            this._treeStoreRight           = new TreeStore();
            this._treeStoreRight.ReadData += new TreeStoreBase.ReadDataEventHandler(this._treeStoreRight_ReadData);
            this._treeModelRight           = new Model();
            if (EnableBatchRemove)
            {
                Ext.Net.Button button3 = new Ext.Net.Button
                {
                    Text      = "<< 全部移除",
                    TextAlign = ButtonTextAlign.Center
                };
                button3.Listeners.Click.Handler = "#{" + this._treePanelRight.ID + "}.submitNodes();";
                buttons.Add(button3);
            }
            Ext.Net.Button button4 = new Ext.Net.Button
            {
                Text      = "< 移  除",
                TextAlign = ButtonTextAlign.Center
            };
            buttons.Add(button4);
            button4.DirectClick += new ComponentDirectEvent.DirectEventHandler(this.btnRemoveSelected_DirectClick);
            button4.DirectEvents.Click.EventMask.Set("正在移除");
            component.Add(buttons.ToArray());
            this.Add(component);
            this.InitTreePanel(this._treePanelRight, this._treeStoreRight, this._treeModelRight);
            base.OnInit(e);
        }
Beispiel #2
0
        //private void LeftItemDblClick_Event(object sender, DirectEventArgs e)
        //{
        //    this.MoveNode(this._treePanelLeft, this._treePanelRight);
        //}

        //private void MoveNode(TreePanel source, TreePanel target)
        //{
        //    List<SubmittedNode> selectedNodes = source.SelectedNodes;
        //    if (selectedNodes != null)
        //    {
        //        if (NodesAdding != null)
        //        {
        //            var nodeIds = selectedNodes.Select(x => Convert.ToInt32(x.NodeID));
        //            var args = new NodesAddEventArgs();
        //            args.NodeIds.AddRange(nodeIds);
        //            NodesAdding(this, args);
        //            if (args.CancelAdd)
        //            {
        //                Ext.Net.X.Msg.Alert("提示", args.ErrorMessage).Show();
        //                return;
        //            }
        //        }
        //        foreach (SubmittedNode node in selectedNodes)
        //        {
        //            target.GetRootNode().InsertChild(0, node.ToProxyNode());
        //            source.GetNodeById(node.NodeID).Remove();
        //            if (target.ID.Contains("Right"))
        //            {
        //                //增加
        //                this._selectedIds.Add(ConvertHelper.ToInt32(node.NodeID));
        //            }
        //            else
        //            {
        //                this._selectedIds.Remove(ConvertHelper.ToInt32(node.NodeID));
        //            }
        //        }
        //    }
        //}

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            var addNodes    = "function(){var nodes=App." + leftPanelId + ".getSelectionModel().getSelection();App." + rightPanelId + ".getRootNode().appendChild(nodes);App." + leftPanelId + ".getRootNode().removeChild(nodes);}";
            var removeNodes = "function(){var nodes=App." + rightPanelId + ".getSelectionModel().getSelection();App." + leftPanelId + ".getRootNode().appendChild(nodes);App." + rightPanelId + ".getRootNode().removeChild(nodes);}";

            this._selectedIds = (List <int>) this.Context.Cache["_selectedIds"];
            if (this._selectedIds == null)
            {
                this._selectedIds = new List <int>();
                this.Context.Cache["_selectedIds"] = this._selectedIds;
            }
            this.Layout = "hbox";
            HBoxLayoutConfig item = new HBoxLayoutConfig
            {
                Align          = HBoxAlign.Middle,
                DefaultMargins = "0"
            };

            this.LayoutConfig.Add(item);
            this._treePanelLeft    = new TreePanel();
            this._treePanelLeft.ID = leftPanelId;
            //_treePanelLeft.DirectEvents.ItemDblClick.Url = LeftItemDblClickUrl;
            //this._treePanelLeft.DirectEvents.ItemDblClick.Event += new ComponentDirectEvent.DirectEventHandler(this.LeftItemDblClick_Event);
            // this._treePanelLeft.SubmitUrl = LeftSubmitUrl;// += new TreePanel.SubmitEventHandler(this._treePanelLeft_Submit);
            //this._treePanelLeft.DirectEvents.Submit.EventMask.Set("正在添加");
            this._treePanelLeft.Title  = "可添加";
            _treePanelLeft.MultiSelect = EnableBatchAdd;
            this._treePanelLeft.Height = this.Height;
            double width = (this.Width.Value - 75.0) / 2.0;

            this._treePanelLeft.Width = new Unit(width);
            this._treeStoreLeft       = new TreeStore();
            //var ajaxProxy = new AjaxProxy();
            //ajaxProxy.ActionMethods.Read = HttpMethod.POST;
            //ajaxProxy.Reader.Add(new JsonReader());
            //ajaxProxy.Url = LeftReadUrl;
            this._treeStoreLeft.Proxy.Add(LeftReadProxy);// += new TreeStoreBase.ReadDataEventHandler(this._treeStoreLeft_ReadData);
            this._treeModelLeft = new Model();
            this.InitTreePanel(this._treePanelLeft, this._treeStoreLeft, this._treeModelLeft);
            Ext.Net.Panel component = new Ext.Net.Panel
            {
                Width       = 75,
                ButtonAlign = Alignment.Center,
                Layout      = "vbox"
            };
            if (!Ext.Net.X.IsAjaxRequest)
            {
                component.Border = false;
            }
            var buttons = new List <Ext.Net.Button>();

            if (EnableBatchAdd)
            {
                Ext.Net.Button button = new Ext.Net.Button
                {
                    Text      = "全部添加 >>",
                    TextAlign = ButtonTextAlign.Center
                };
                button.Listeners.Click.Handler = "function(){var nodes=Ext.Array.clone(App." + leftPanelId + ".getRootNode().childNodes);App." + leftPanelId + ".getRootNode().removeAll(false);App." + rightPanelId + ".getRootNode().appendChild(nodes);}";
                buttons.Add(button);
            }
            Ext.Net.Button btnAdd = new Ext.Net.Button
            {
                Text      = "添  加 > ",
                TextAlign = ButtonTextAlign.Center
            };
            buttons.Add(btnAdd);
            //btnAdd.DirectClickUrl = AddUrl;
            //btnAdd.DirectClick += new ComponentDirectEvent.DirectEventHandler(this.btnAddSelected_DirectClick);
            //btnAdd.DirectEvents.Click.EventMask.Set("正在添加");
            this._treePanelRight       = new TreePanel();
            this._treePanelRight.ID    = rightPanelId;
            this._treePanelRight.Title = "已添加";
            //_treePanelRight.SubmitUrl = RightSubmitUrl;
            //this._treePanelRight.DirectEvents.Submit.EventMask.Set("正在移除");
            //this._treePanelRight.Submit += new TreePanel.SubmitEventHandler(this._treePanelRight_Submit);
            _treePanelRight.MultiSelect = EnableBatchRemove;
            this._treePanelRight.Height = this.Height;
            _treePanelRight.Listeners.ItemDblClick.Fn = removeNodes;
            //this._treePanelRight.DirectEvents.ItemDblClick.Url = RightItemDblClick;//.Event += new ComponentDirectEvent.DirectEventHandler(this.RightItemDblClick_Event);
            this._treePanelRight.Width = new Unit(width);
            this._treeStoreRight       = new TreeStore();
            _treeStoreRight.Proxy.Add(RightReadProxy);
            //this._treeStoreRight.ReadData += new TreeStoreBase.ReadDataEventHandler(this._treeStoreRight_ReadData);
            this._treeModelRight = new Model();
            if (EnableBatchRemove)
            {
                Ext.Net.Button btnRemoveAll = new Ext.Net.Button
                {
                    Text      = "<< 全部移除",
                    TextAlign = ButtonTextAlign.Center
                };
                btnRemoveAll.Listeners.Click.Handler = "function(){var nodes=Ext.Array.clone(App." + rightPanelId + ".getRootNode().childNodes);App." + leftPanelId + ".getRootNode().removeAll(false);App." + leftPanelId + ".getRootNode().appendChild(nodes);}";
                buttons.Add(btnRemoveAll);
            }
            Ext.Net.Button btnRemove = new Ext.Net.Button
            {
                Text      = "< 移  除",
                TextAlign = ButtonTextAlign.Center
            };
            buttons.Add(btnRemove);
            btnAdd.Handler = addNodes;
            _treePanelLeft.Listeners.ItemDblClick.Fn = addNodes;
            btnRemove.Listeners.Click.Fn             = removeNodes;
            //btnRemove.DirectClickUrl = RemoveRightUrl;// += new ComponentDirectEvent.DirectEventHandler(this.btnRemoveSelected_DirectClick);
            //btnRemove.DirectEvents.Click.EventMask.Set("正在移除");
            component.Add(buttons.ToArray());
            this.Add(component);
            this.InitTreePanel(this._treePanelRight, this._treeStoreRight, this._treeModelRight);
        }