// public event TreeStoreBase.ReadDataEventHandler RightReadData;

        //private void _treePanelLeft_Submit(object sender, SubmitEventArgs e)
        //{
        //    List<SubmittedNode> children = e.RootNode.Children;
        //    foreach (SubmittedNode node in children)
        //    {
        //        Ext.Net.Node node2 = new Ext.Net.Node
        //        {
        //            NodeID = node.NodeID,
        //            Text = node.Text,
        //            Leaf = true
        //        };
        //        this._treePanelRight.GetRootNode().InsertChild(0, node2);
        //        this._treePanelLeft.GetNodeById(node.NodeID).Remove();
        //        this._selectedIds.Add(ConvertHelper.ToInt32(node.NodeID));
        //    }
        //}

        //private void _treePanelRight_Submit(object sender, SubmitEventArgs e)
        //{
        //    List<SubmittedNode> children = e.RootNode.Children;
        //    foreach (SubmittedNode node in children)
        //    {
        //        Ext.Net.Node node2 = new Ext.Net.Node
        //        {
        //            NodeID = node.NodeID,
        //            Text = node.Text,
        //            Leaf = true
        //        };
        //        this._treePanelLeft.GetRootNode().InsertChild(0, node2);
        //        this._treePanelRight.GetNodeById(node.NodeID).Remove();
        //        this._selectedIds.Remove(ConvertHelper.ToInt32(node.NodeID));
        //    }
        //}

        //private void _treeStoreLeft_ReadData(object sender, NodeLoadEventArgs e)
        //{
        //    if (this.LeftReadData != null)
        //    {
        //        this.LeftReadData(sender, e);
        //    }
        //}

        //private void _treeStoreRight_ReadData(object sender, NodeLoadEventArgs e)
        //{
        //    if (this.RightReadData != null)
        //    {
        //        this.RightReadData(sender, e);
        //        foreach (Ext.Net.Node node in e.Nodes)
        //        {
        //            this._selectedIds.Add(ConvertHelper.ToInt32(node.NodeID));
        //        }
        //    }
        //}

        //public void AddSelected()
        //{
        //    MoveNode(this._treePanelLeft, this._treePanelRight);
        //}

        //private void btnAddSelected_DirectClick(object sender, DirectEventArgs e)
        //{
        //    this.MoveNode(this._treePanelLeft, this._treePanelRight);
        //}

        //private void btnRemoveSelected_DirectClick(object sender, DirectEventArgs e)
        //{
        //    this.MoveNode(this._treePanelRight, this._treePanelLeft);
        //}

        /// <summary>
        /// 获取已选择的记录
        /// </summary>
        /// <returns></returns>
        //public int[] GetSelected(bool clearCahce = true)
        //{
        //    int[] numArray = this._selectedIds.ToArray();
        //    if (clearCahce)
        //    {
        //        this.Context.Cache.Remove("_selectedIds");
        //    }
        //    return numArray;
        //}

        private void InitTreePanel(TreePanel treePanel, TreeStore treeStore, Model model)
        {
            treePanel.RootVisible = false;
            treePanel.AutoDataBind = true;
            Ext.Net.Parameter parameters = new Ext.Net.Parameter
            {
                Name = "id",
                Value = "record.data.id",
                Mode = ParameterMode.Raw
            };
            var view = new Ext.Net.TreeView();
            view.Plugins.Add(new TreeViewDragDrop()
            {
                AppendOnly = true
            });
            treePanel.View.Add(view);
            //treePanel.DirectEvents.ItemDblClick.ExtraParams.Add(parameters);
            //treePanel.DirectEvents.ItemDblClick.EventMask.ShowMask = true;
            //treePanel.DirectEvents.ItemDblClick.EventMask.Msg = "正在添加";
            treeStore.AutoDataBind = true;
            treeStore.AutoLoad = true;
            model.Fields.Add(new ModelField("Id", ModelFieldType.Int));
            model.Fields.Add(new ModelField("Name", ModelFieldType.String));
            treeStore.Model.Add(model);
            treePanel.Store.Add(treeStore);
            Ext.Net.Node item = new Ext.Net.Node
            {
                NodeID = "0",
                Text = "根"
            };
            treeStore.Root.Add(item);
            Add(treePanel);
        }
        //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);
        }
Example #3
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            #region 总体布局
            _viewPort = new Viewport();
            _viewPort.Layout = "border";
            _copyright = new Panel();
            _copyright.Title = "版权";
            _copyright.TitleAlign = TitleAlign.Center;
            _copyright.Collapsible = false;
            _copyright.Region = Region.South;
            _copyright.Split = true;
            _menu = new Panel();
            _menu.Title = "导航菜单";
            _menu.Collapsible = true;
            _menu.Region = Region.West;
            _menu.Split = true;
            _menu.Width = 200;
            _workArea = new Ext.Net.TabPanel();
            _workArea.Title = "欢迎使用";
            _workArea.Region = Region.Center;
            _workArea.ID = "tabWork";
            _title = new Panel();
            _title.Title = WebName;
            _title.Collapsible = false;
            _title.Region = Region.North;
            _title.Split = true;
            _viewPort.Items.Add(_title);
            _viewPort.Items.Add(_workArea);
            _viewPort.Items.Add(_copyright);
            _viewPort.Items.Add(_menu);
            #endregion

            #region 个人区
            _personPanel = new Ext.Net.Panel();
            _personPanel.Collapsed = true;
            _personPanel.Collapsible = true;
            _personPanel.Title = "欢迎使用";
            _personPanel.Height = 110;
            _personPanel.BodyPadding = 10;
            _personPanel.Layout = "table";
            _personPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            Image avatarImg = new Image();
            avatarImg.RowSpan = 2;
            avatarImg.Width = avatarImg.Height = 70;
            avatarImg.ImageUrl = BaseResource.avatar;
            _personPanel.Add(avatarImg);
            _personPanel.Add(new Label(userInfo.Username));

            ButtonGroup buttonGroup = new ButtonGroup();
            buttonGroup.Width = 80;
            buttonGroup.Layout = "vbox";
            buttonGroup.Add(new KeyButton()
            {
                Text = "修改密码",
                ID = "btnChangePassword",
                OnClientClick = "App.winChangePassword.show();App.winChangePassword.getLoader().load();"
            });

            btnExit = new Button()
            {
                Text = "安全退出",
                ID = "btnExit",
                Icon = Icon.KeyDelete
            };
            var clickEvent = btnExit.DirectEvents.Click;
            clickEvent.Event += clickEvent_Event;
            clickEvent.EventMask.Set("正在退出");
            clickEvent.Confirmation.ConfirmRequest = true;
            clickEvent.Confirmation.Title = "提示";
            clickEvent.Confirmation.Message = "确定退出?";
            buttonGroup.Add(btnExit);
            _personPanel.Add(buttonGroup);
            _menu.Add(_personPanel);
            winChangePassword = new Window()
            {
                Icon = Icon.Key,
                BodyPadding = 10,
                Width = 300,
                Height = 210,
                Modal = true,
                Hidden = true,
                AutoShow = false,
                ID = "winChangePassword",
                Title = "修改密码",
                Loader = new ComponentLoader()
                {
                    Url = ResolveClientUrl("~/user/changepassword.aspx"),
                    Mode = LoadMode.Frame
                }
            };
            winChangePassword.Loader.LoadMask.Set("正在加载");
            Controls.Add(winChangePassword);
            #endregion

            _menuPanel = new TreePanel()
            {
                Title = "功能菜单",
                Height = 500,
                RootVisible = false,
                ID = "mainMenu"
            };

            _menuStore = new TreeStore()
            {
                NodeParam = "parentId"
            };
            _menuStore.ReadData += _menuStore_ReadData;
            _menuPanel.Store.Add(_menuStore);
            _menuPanel.Root.Add(new Node()
            {
                NodeID = "0",
                Text = "Root",
                Expanded = true
            });
            _menu.Add(_menuPanel);
            var itemClick = _menuPanel.DirectEvents.ItemClick;
            itemClick.Before = "var tree=arguments[0],eventType=arguments[1],eventName=arguments[2],extraParams=arguments[3];var tab = App.tabWork.getComponent('menu' + extraParams.id);if (tab) {App.tabWork.setActiveTab(tab);return false;}return tree.getStore().getNodeById(extraParams.id).isLeaf();";
            itemClick.EventMask.Set("正在加载");
            itemClick.Event += itemClick_Event;
            itemClick.ExtraParams.Add(new Parameter("id", "record.data.id", ParameterMode.Raw));

            #region 隐藏顶级窗口
            _winParentWindow = new Window();
            _winParentWindow.Hidden = true;
            _winParentWindow.Loader = new ComponentLoader();
            _winParentWindow.Loader.Mode = LoadMode.Frame;
            _winParentWindow.Width = 800;
            _winParentWindow.Modal = true;
            _winParentWindow.Height = 600;
            _winParentWindow.ID = "_topWin";
            Controls.Add(_winParentWindow);
            #endregion

            Controls.Add(_viewPort);
        }
Example #4
0
        protected override void OnLoad(EventArgs e)
        {
            if (this._nodeHelper == null)
            {
                _nodeHelper = new NodeHelper(Table);
            }
            TreeStore.Config config = new TreeStore.Config
            {
                NodeParam = "parentId"
            };
            this._treeStore = new TreeStore(config);
            this._treeStore.ID = "_treeStore";
            Model model = new Model
            {
                Fields = { new ModelField("Id", ModelFieldType.String), new ModelField("Name", ModelFieldType.String), new ModelField("ParentId", ModelFieldType.String) }
            };
            model.Fields.AddRange(this._nodeHelper.CustomFields);
            this._treeStore.Model.Add(model);
            this._treeStore.Proxy.Add(new PageProxy());
            this.Store.Add(this._treeStore);
            this._treeStore.ReadData += new TreeStoreBase.ReadDataEventHandler(this.treeStore_ReadData);
            base.RemoteRemove += new TreePanel.RemoteRemoveEventHandler(this.TreePanelEx_RemoteRemove);
            base.RemoteEdit += new TreePanel.RemoteEditEventHandler(this.TreePanelEx_RemoteEdit);
            base.RemoteMove += new TreePanel.RemoteMoveEventHandler(this.TreePanelEx_RemoteMove);
            Ext.Net.Button button = new Ext.Net.Button
            {
                Text = "刷新",
                Handler = "App." + this.ID + ".getStore().load();"
            };
            Toolbar toolbar = new Toolbar();
            toolbar.Items.Add(button);
            this.TopBar.Add(toolbar);
            if (!Ext.Net.X.IsAjaxRequest)
            {
                //base.Listeners.NodeDragOver.Handler = "var recs = dragData.records;var prev=-1;for(var i=0;i<recs.length;i++){var recData=recs[i].data;if(prev==-1){prev=recData.Level;}else{if(prev!=recData.Level){return false;}}}if(targetNode.data.Level>=" + this.Level + ")return false;return true;";
                Parameter parameters = new Parameter
                {
                    Name = "parentId",
                    Value = "arguments[1].data.parentId",
                    Mode = ParameterMode.Raw
                };
                this.RemoteExtraParams.Add(parameters);
                this.On("beforeRemoteAction", new JFunction("Ext.net.Mask.show({ msg : '正在加载' });"));
                JFunction fn = new JFunction("Ext.net.Mask.hide();");
                this.On("remoteActionRefusal", fn);
                this.On("remoteActionException", fn);
                this.On("remoteActionSuccess", fn);
                this.On("remoteEditRefusal", new JFunction("Ext.Msg.alert('失败了')"));
                this._treeStore.On("beforeload", new JFunction("Ext.net.Mask.show({ msg : '正在加载' });"));
                this._treeStore.On("load", new JFunction("Ext.net.Mask.hide();"));
                Ext.Net.Node node = new Ext.Net.Node();
                node.CustomAttributes.Add(new ConfigItem("Id", ""));
                node.CustomAttributes.Add(new ConfigItem("Name", "根"));
                node.NodeID = "0";
                node.Expanded = true;
                node.Text = "根";
                this.Root.Add(node);
                Column column = new Column();
                this.ColumnModel.Columns.Add(column);
                TreeColumn column2 = new TreeColumn();
                this.ColumnModel.Columns.Add(column2);
                ActionColumn column3 = new ActionColumn();
                if (this.EnableRemove)
                {
                    ActionItem item2 = new ActionItem();
                    column3.Items.Add(item2);
                    item2.Icon = Ext.Net.Icon.PageWhiteDelete;
                    item2.Handler = "var record=arguments[5];var tree = App." + this.ID + ";var node = tree.getStore().getNodeById(record.data.Id) || tree.getStore().getNewRecords()[0];Ext.Msg.confirm(\"提示\", \"会删除相关的数据,无法恢复,确认删除?\", function (r) {if (r == \"yes\") {tree.removeNode(node);return;App.direct.RemoveNode(record.data.Id, {success: function (result) {if (result.Success) {node.remove();node.commit();} else {Ext.Msg.alert(\"错误\", result.Message);}},eventMask: {showMask: true,msg: \"正在删除\"}});}});";
                    item2.Tooltip = "删除";
                }
                this.ColumnModel.Columns.Add(column3);
                column.ID = "col1";
                column.DataIndex = "Id";
                column.Width = 50;
                column.Text = "编号";
                column2.ID = "col2";
                column2.DataIndex = "Name";
                column2.Width = 300;
                column2.Text = "名称";
                column3.ID = "col3";
                column3.Text = "操作";
                column3.Width = 60;
                column3.Align = Alignment.Center;
                if (EnableEdit)
                {
                    ActionItem item = new ActionItem();
                    column3.Items.Add(item);
                    item.Icon = Ext.Net.Icon.PageWhiteAdd;
                    item.Handler = "var record=arguments[5]; var tree = App." + this.ID + ";var ep = tree.editingPlugin;var node,store = tree.getStore();if (record.data.Id) {node = store.getNodeById(record.data.Id);}else{node = store.getRootNode();}node.expand(false, function () {node = node.appendChild({Name:'新节点'});setTimeout(function () {ep.startEdit(node, tree.columns[1]);}, 200);});";
                    item.Tooltip = "添加子节点";
                    CellEditing editing = new CellEditing();
                    editing.Listeners.CancelEdit.Handler = " if (e.record.data.Id) {e.record.reject();} else {e.record.remove(true);}";
                    this.Plugins.Add(editing);
                    this.Editor.Add(new TextField());
                    TreeView view = new TreeView();
                    this.View.Add(view);
                    TreeViewDragDrop drop = new TreeViewDragDrop
                    {
                        DragText = "移动到",
                        AppendOnly = true
                    };
                    view.Plugins.Add(drop);
                }
                this.Mode = TreePanelMode.Remote;

            }
            base.OnLoad(e);
        }
        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);
        }
 private void InitTreePanel(TreePanel treePanel, TreeStore treeStore, Model model)
 {
     treePanel.RootVisible = false;
     treePanel.AutoDataBind = true;
     Ext.Net.Parameter parameters = new Ext.Net.Parameter
     {
         Name = "id",
         Value = "record.data.id",
         Mode = ParameterMode.Raw
     };
     treePanel.DirectEvents.ItemDblClick.ExtraParams.Add(parameters);
     treePanel.DirectEvents.ItemDblClick.EventMask.ShowMask = true;
     treePanel.DirectEvents.ItemDblClick.EventMask.Msg = "正在添加";
     treeStore.AutoDataBind = true;
     treeStore.AutoLoad = true;
     model.Fields.Add(new ModelField("Id", ModelFieldType.Int));
     model.Fields.Add(new ModelField("Name", ModelFieldType.String));
     treeStore.Model.Add(model);
     treeStore.Proxy.Add(new PageProxy());
     treePanel.Store.Add(treeStore);
     Ext.Net.Node item = new Ext.Net.Node
     {
         NodeID = "0",
         Text = "根",
         Expanded = true
     };
     treeStore.Root.Add(item);
     Add(treePanel);
 }
Example #7
0
        public override void RenderView(System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer)
        {
            writer.Write("<!DOCTYPE html>");
            writer.Write("<head>");
            writer.Write("<title>后台管理中心 - " + AppConfig.WebTitle + "</title>");
            writer.Write("</head><body></body>");
            var x = Html.X();
            writer.Write(x.ResourceManager().ToHtmlString());
            #region 总体布局
            var viewPort = new Viewport();
            viewPort.Layout = "border";
            var _copyright = new Panel();
            _copyright.Title = AppConfig.WebName + " 版权所有";
            _copyright.TitleAlign = TitleAlign.Center;
            _copyright.Collapsible = false;
            _copyright.Region = Region.South;
            _copyright.Split = true;
            var _menu = new Panel();
            _menu.Title = "导航菜单";
            _menu.Collapsible = true;
            _menu.Region = Region.West;
            _menu.Split = true;
            _menu.Width = 200;
            var _workArea = new Ext.Net.TabPanel();
            _workArea.Title = "欢迎使用";
            _workArea.Region = Region.Center;
            _workArea.ID = "tabWork";
            var _title = new Panel();
            _title.Title = AppConfig.WebTitle;
            _title.Collapsible = false;
            _title.Region = Region.North;
            _title.Split = true;
            viewPort.Items.Add(_title);
            viewPort.Items.Add(_workArea);
            viewPort.Items.Add(_copyright);
            viewPort.Items.Add(_menu);
            #endregion

            #region 个人区
            var _personPanel = new Ext.Net.Panel();
            _personPanel.Collapsed = true;
            _personPanel.Collapsible = true;
            _personPanel.Title = "欢迎使用";
            _personPanel.Height = 110;
            _personPanel.BodyPadding = 10;
            _personPanel.Layout = "table";
            _personPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            Image avatarImg = new Image();
            avatarImg.RowSpan = 2;
            avatarImg.Width = avatarImg.Height = 70;
            //avatarImg.ImageUrl = BaseResource.avatar;
            _personPanel.Add(avatarImg);
            _personPanel.Add(new Label(UserInfo.Username));

            ButtonGroup buttonGroup = new ButtonGroup();
            buttonGroup.Width = 80;
            buttonGroup.Layout = "vbox";
            buttonGroup.Add(new Button()
            {
                Icon= Ext.Net.Icon.Key,
                Text = "修改密码",
                ID = "btnChangePassword",
                OnClientClick = "App.winChangePassword.show();App.winChangePassword.getLoader().load();"
            });

            var btnExit = new Button()
            {
                Text = "安全退出",
                ID = "btnExit",
                Icon = Icon.KeyDelete
            };

            buttonGroup.Add(btnExit);
            _personPanel.Add(buttonGroup);
            _menu.Add(_personPanel);
            var winChangePassword = new Window()
            {
                Icon = Icon.Key,
                BodyPadding = 10,
                Width = 300,
                Height = 210,
                Modal = true,
                Hidden = true,
                AutoShow = false,
                ID = "winChangePassword",
                Title = "修改密码",
                Loader = new ComponentLoader()
                {
                    Url = Url.Action("changePassword", "account"),
                    Mode = LoadMode.Frame
                }
            };
            #endregion

            var _menuPanel = new TreePanel()
            {
                Title = "功能菜单",
                Height = 500,
                RootVisible = false,
                ID = "mainMenu"
            };

            var _menuStore = new TreeStore()
             {
                 NodeParam = "parentId"
             };
            _menuStore.Proxy.Add(x.AjaxProxy().Url(Url.Action("GetMenus")).ActionMethods(y => y.Read = HttpMethod.POST));
            //_menuStore.ReadData += _menuStore_ReadData;
            _menuPanel.Store.Add(_menuStore);
            _menuPanel.Root.Add(new Node()
            {
                NodeID = "0",
                Text = "Root",
                Expanded = true
            });
            _menu.Add(_menuPanel);
            var itemClick = _menuPanel.DirectEvents.ItemClick;
            itemClick.Before = "var tree=arguments[0],eventType=arguments[1],eventName=arguments[2],extraParams=arguments[3];var tab = App.tabWork.getComponent('menu' + extraParams.menuid);if (tab) {App.tabWork.setActiveTab(tab);return false;}return tree.getStore().getNodeById(extraParams.menuid).isLeaf();";
            itemClick.Url = Url.Action("OpenPage");
            itemClick.ExtraParams.Add(new Parameter("menuid", "record.data.id", ParameterMode.Raw));
            writer.Write(viewPort.ToBuilder().ToHtmlString());
        }