Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        public CommandColumn.Builder CommandColumn(CommandColumn component)
        {
#if MVC
            component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null;
#endif
            return(new CommandColumn.Builder(component));
        }
Exemple #2
0
        private string GetColumnPlugins()
        {
            StringBuilder sb = new StringBuilder("[");

            for (int i = 0; i < this.ColumnModel.Columns.Count; i++)
            {
                CommandColumn      cmdCol    = this.ColumnModel.Columns[i] as CommandColumn;
                ImageCommandColumn imgCmdCol = this.ColumnModel.Columns[i] as ImageCommandColumn;
                Column             column    = this.ColumnModel.Columns[i] as Column;

                if (column != null && column.Commands.Count > 0 && imgCmdCol == null)
                {
                    continue;
                }

                if (cmdCol != null || imgCmdCol != null)
                {
                    sb.Append(i + ",");
                    continue;
                }

                CheckColumn cc = this.ColumnModel.Columns[i] as CheckColumn;

                if (cc != null && cc.Editable)
                {
                    sb.Append(i + ",");
                    continue;
                }

                RatingColumn rc = this.ColumnModel.Columns[i] as RatingColumn;

                if (rc != null && rc.Editable)
                {
                    sb.Append(i + ",");
                    continue;
                }
            }

            if (sb[sb.Length - 1] == ',')
            {
                sb.Remove(sb.Length - 1, 1);
            }

            sb.Append("]");

            return(sb.ToString());
        }
Exemple #3
0
 /// <summary>
 /// 设置Ext中GridCommand
 /// </summary>
 /// <param name="cmds"></param>
 private void setCommandColumn(Ext.Net.CommandColumn cmds)
 {
     foreach (object cmd in cmds.Commands)
     {
         if (cmd is Ext.Net.GridCommand)
         {
             bool check = checkControlActionPermit(cmd as Ext.Net.GridCommand);
             if (!check)
             {
                 setControlAction(cmd as Ext.Net.GridCommand, check);
             }
             else
             {
                 setCommandColumn((cmd as Ext.Net.GridCommand).Menu);
             }
         }
     }
 }
 private static void AddCommand(CommandColumn commandColumn, Icon icon, string command, string text)
 {
     GridCommand gridCommand = new GridCommand
     {
         Icon = icon,
         Text = text,
         CommandName = command
     };
     commandColumn.Commands.Add(gridCommand);
 }
        private void CreateColumnModel()
        {
            ColumnModel.Columns.Add(new RowNumbererColumn());

            Column iconColumn = new Column
            {
                ColumnID = "IconUrl",
                DataIndex = "IconUrl",
                Width = 30
            };
            iconColumn.Renderer.Fn = "childrenEditorRenderIcon";
            ColumnModel.Columns.Add(iconColumn);

            ColumnModel.Columns.Add(new Column
            {
                ColumnID = "ID",
                Header = "ID",
                DataIndex = "ID",
                Width = 50
            });
            ColumnModel.Columns.Add(new Column
            {
                ColumnID = "Title",
                Header = "Title",
                DataIndex = "Title",
                Width = 200
            });

            CommandColumn commandColumn = new CommandColumn
            {
                Width = 120,
                PrepareToolbar = { Fn = "childrenEditorPrepareCommandToolbar" }
            };
            AddCommand(commandColumn, Icon.NoteEdit, "Edit", "Edit");
            AddCommand(commandColumn, Icon.Delete, "Delete", "Remove");
            ColumnModel.Columns.Add(commandColumn);

            Listeners.Command.Handler = string.Format(@"
                switch (command)
                {{
                    case 'Edit' :
                        var editorWindow = Ext.getCmp('{0}editorWindow' + rowIndex);
                        editorWindow.record = record;
                        editorWindow.show();
                        break;
                }}", Parent.ClientID);

            Listeners.RowClick.Handler = string.Format(@"
            var record = {0}.getStore().getAt(rowIndex);
            if (record.removed) {{
                    {0}.getSelectionModel().deselectRow(rowIndex);
            }}", ClientID);

            DirectEvents.Command.Event += OnGridPanelCommand;
            DirectEvents.Command.ExtraParams.Add(new Parameter("Command", "command", ParameterMode.Raw));
            DirectEvents.Command.ExtraParams.Add(new Parameter("Index", "rowIndex", ParameterMode.Raw));
            DirectEvents.Command.Success = string.Format("if (extraParams['Command'] == 'Delete') flagRemovedItem({0}, extraParams['Index']);",
                ClientID);

            SelectionModel.Add(new RowSelectionModel
            {
                Listeners =
                {
                    RowSelect = { Handler = _removeItemsButton.ClientID + ".enable();" },
                    RowDeselect =
                    {
                        Handler = string.Format("if (!{0}.hasSelection()) {{ {1}.disable(); }}",
                            this.ClientID, _removeItemsButton.ClientID)
                    }
                }
            });
        }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 public CommandColumn.Builder CommandColumn(CommandColumn component)
 {
     return(new CommandColumn.Builder(component));
 }
Exemple #7
0
 private void InitGridCommand(CommandColumn commandColumn)
 {
     commandColumn.ID = "_cmdCol";
     commandColumn.Sortable = false;
     commandColumn.Listeners.Command.Handler = "";//.DirectEvents.Command.EventMask.Msg = "正在加载";
     //commandColumn.DirectEvents.Command.EventMask.ShowMask = true;
     //commandColumn.DirectEvents.Command.Url = CommandUrl;//.Event += new ComponentDirectEvent.DirectEventHandler(this.Command_Event);
     ParameterCollection extraParams = commandColumn.DirectEvents.Command.ExtraParams;
     if (this.EditorConfig != null)
     {
         Parameter parameters = new Parameter
         {
             Name = "command",
             Value = "command",
             Mode = ParameterMode.Raw
         };
         this.EditorConfig.ExtraParams.Add(parameters);
         Parameter parameter3 = new Parameter
         {
             Name = "id",
             Value = "record.data.Id",
             Mode = ParameterMode.Raw
         };
         this.EditorConfig.ExtraParams.Add(parameter3);
         foreach (Parameter parameter in this.EditorConfig.ExtraParams)
         {
             Parameter param1 = parameter;
             if (extraParams.All<Parameter>(x => x.Name != param1.Name))
             {
                 extraParams.Add(parameter);
             }
         }
     }
 }
Exemple #8
0
 private void InitGridCommand()
 {
     if ((this.EditorConfig != null) && (this.EditorConfig.Mode == EditorMode.Window))
     {
         Window window = new Window
         {
             AutoShow = false,
             Hidden = true,
             CloseAction = CloseAction.Hide,
             Closable = true,
             ConstrainHeader = true,
             Constrain = true,
             Modal = true,
             BodyPadding = 10
         };
         ComponentLoader loader = new ComponentLoader
         {
             DisableCaching = true,
             AutoLoad = false,
             Mode = LoadMode.Frame
         };
         window.Loader = loader;
         this._editWindow = window;
         this._editWindow.Loader.LoadMask.ShowMask = true;
         this._editWindow.Loader.LoadMask.Msg = "正在加载";
         this._editWindow.ID = "editWindow";
         _editWindow.Resizable = false;
         _editWindow.Icon = Ext.Net.Icon.UserAdd;
         this.Controls.Add(this._editWindow);
         CommandColumn item = (CommandColumn)this.ColumnModel.Columns.FirstOrDefault<ColumnBase>(x => (x is CommandColumn));
         GridCommand command = null;
         if (this.EnableEdit)
         {
             command = new GridCommand
             {
                 Text = "编辑",
                 Icon = Ext.Net.Icon.ApplicationEdit,
                 CommandName = "edit"
             };
         }
         GridCommand commandRemove = null;
         if (this.EnableRemove)
         {
             commandRemove = new GridCommand
             {
                 Text = "删除",
                 Icon = Ext.Net.Icon.ApplicationDelete,
                 CommandName = "delete"
             };
         }
         if (item == null)
         {
             item = new CommandColumn();
             item.DirectEvents.Command.Confirmation.ConfirmRequest = true;
             item.DirectEvents.Command.Confirmation.Message = "确认删除?";
             item.DirectEvents.Command.Confirmation.Title = "提示";
             item.DirectEvents.Command.Confirmation.BeforeConfirm = "if(command=='delete')return true;return false;";
             item.Width = 150;
             if (this.EnableEdit)
             {
                 item.Commands.Add(command);
             }
             if (this.EnableRemove)
             {
                 item.Commands.Add(commandRemove);
             }
             this.ColumnModel.Columns.Insert(0, item);
             this.InitGridCommand(item);
             if (EditorConfig.EditWindow != null)
             {
                 var replaceParamsScripts = new List<string>();
                 var scriptTpl = "url=url.replace('{0}',{1});";
                 foreach (var paras in EditorConfig.EditWindow.ExtraParams)
                 {
                     var script = string.Format(scriptTpl, "@" + paras.Name, paras.Value);
                     replaceParamsScripts.Add(script);
                 }
                 item.Listeners.Command.Handler = "if(command==\"edit\"){var url='" + EditorConfig.EditWindow.Url + "';" + string.Join(";", replaceParamsScripts) + "var editWindow=App." + _editWindow.ID + ";editWindow.show();editWindow.loader.load({url:url});editWindow.setTitle(\"" + EditorConfig.EditWindow.Title + "\");editWindow.setWidth(" + EditorConfig.EditWindow.Width + ");editWindow.setHeight(" + EditorConfig.EditWindow.Height + ");editWindow.center();}else{Ext.Msg.confirm(\"提示\",\"确认删除吗?\",function(r){if(r==\"yes\"){               }})}";
                 //item.DirectEvents.Command.ExtraParams.AddRange(this.EditorConfig.EditWindow.ExtraParams);
             }
         }
         else
         {
             GridCommand commandEdit = (GridCommand)item.Commands.FirstOrDefault<GridCommandBase>(x => (((GridCommand)x).CommandName == "edit"));
             if (commandEdit == null)
             {
                 commandEdit = command;
                 this.InitGridCommand(item);
                 if (EnableRemove)
                     item.Commands.Insert(0, commandRemove);
                 if (EnableEdit)
                     item.Commands.Insert(0, commandEdit);
                 if (EditorConfig.EditWindow != null)
                     item.DirectEvents.Command.ExtraParams.AddRange(this.EditorConfig.EditWindow.ExtraParams);
             }
         }
     }
 }
Exemple #9
0
 private void InitGridCommand()
 {
     if ((this.EditorConfig != null) && (this.EditorConfig.Mode == EditorMode.Window))
     {
         Window window = new Window
         {
             AutoShow = false,
             Hidden = true,
             CloseAction = CloseAction.Hide,
             Closable = true,
             ConstrainHeader = true,
             Constrain = true,
             Modal = true,
             BodyPadding = 10
         };
         ComponentLoader loader = new ComponentLoader
         {
             DisableCaching = true,
             AutoLoad = false,
             Mode = LoadMode.Frame
         };
         window.Loader = loader;
         this._editWindow = window;
         this._editWindow.Loader.LoadMask.ShowMask = true;
         this._editWindow.Loader.LoadMask.Msg = "正在加载";
         this._editWindow.ID = "_editWindow";
         this.Controls.Add(this._editWindow);
         CommandColumn item = (CommandColumn)this.ColumnModel.Columns.FirstOrDefault<ColumnBase>(x => (x is CommandColumn));
         GridCommand command = null;
         if (this.EnableEdit)
         {
             command = new GridCommand
             {
                 Text = "编辑",
                 Icon = Ext.Net.Icon.ApplicationEdit,
                 CommandName = "edit"
             };
         }
         GridCommand commandRemove = null;
         if (this.EnableRemove)
         {
             commandRemove = new GridCommand
             {
                 Text = "删除",
                 Icon = Ext.Net.Icon.ApplicationDelete,
                 CommandName = "delete"
             };
         }
         if (item == null)
         {
             item = new CommandColumn();
             item.DirectEvents.Command.Confirmation.ConfirmRequest = true;
             item.DirectEvents.Command.Confirmation.Message = "确认删除?";
             item.DirectEvents.Command.Confirmation.Title = "提示";
             item.DirectEvents.Command.Confirmation.BeforeConfirm = "if(command=='delete')return true;return false;";
             item.Width = 150;
             if (this.EnableEdit)
             {
                 item.Commands.Add(command);
             }
             if (this.EnableRemove)
             {
                 item.Commands.Add(commandRemove);
             }
             this.ColumnModel.Columns.Insert(0, item);
             this.InitGridCommand(item);
             if (EditorConfig.EditWindow != null)
                 item.DirectEvents.Command.ExtraParams.AddRange(this.EditorConfig.EditWindow.ExtraParams);
         }
         else
         {
             GridCommand commandEdit = (GridCommand)item.Commands.FirstOrDefault<GridCommandBase>(x => (((GridCommand)x).CommandName == "edit"));
             if (commandEdit == null)
             {
                 commandEdit = command;
                 this.InitGridCommand(item);
                 if (EnableRemove)
                     item.Commands.Insert(0, commandRemove);
                 if (EnableEdit)
                     item.Commands.Insert(0, commandEdit);
                 if (EditorConfig.EditWindow != null)
                     item.DirectEvents.Command.ExtraParams.AddRange(this.EditorConfig.EditWindow.ExtraParams);
             }
         }
     }
 }