public CommandColumn CreateCommandColumn() { var column = new CommandColumn() { ID = "CustomCommands", Width = new Unit(Width), MenuDisabled = true, Align = Alignment.Center, Locked = Locked }; if (!string.IsNullOrEmpty(PrepareToolbarFunction)) { column.PrepareToolbar.Fn = PrepareToolbarFunction; } if (!string.IsNullOrEmpty(ListenerCommandHandler)) { column.Listeners.Command.Handler = ListenerCommandHandler; } column.PreRender += AddCommandItems; ConfigureColumnHandler?.Invoke(column); return(column); void AddCommandItems(object sender, EventArgs e) { foreach (var command in GridCommands) { column.Commands.Add(command); } } }
private void InitGridCommand(CommandColumn commandColumn) { commandColumn.ID = "_cmdCol"; commandColumn.Sortable = false; commandColumn.DirectEvents.Command.EventMask.Msg = "正在加载"; commandColumn.DirectEvents.Command.EventMask.ShowMask = true; commandColumn.DirectEvents.Command.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); } } } }
private CommandColumn GetDeleteCommand() { var deleteCommand = new CommandColumn { ID = "delCommand" + ID, Width = 24, Enabled = !ReadOnly, }; var editCommand = new GridCommand { CommandName = "Delete", Icon = Icon.Cross, }; editCommand.ToolTip.Text = Web.Controls.Properties.Resources.SDeleteText; deleteCommand.Commands.Add(editCommand); deleteCommand.Listeners.Command.Handler = string.Format( "#{{{0}}}.remove(record); var field = #{{{1}}}; var fn = field.{2}; if (fn != null) fn(field.getValue()); field.fireEvent('change', field);", ValuesStoreID, ID, ScriptFunctionConstant.OnChangedValues); deleteCommand.Hidden = ReadOnly; return(deleteCommand); }
public void SetUp() { theColumn = new CommandColumn <Case, CaseActionModel>(CommandKey.Action); theHarness = new ColumnFillerHarness(); theDto = theHarness.RunColumn <Case>(theColumn, x => { x.SetValue(c => c.Id, _id); }); theColumnModel = theColumn.ToDictionary().Single(); }
protected virtual void AddDeleteButton(StringBuilder listener, CommandColumn commandColumn) { var editCommand = new GridCommand { CommandName = "Delete", Icon = Icon.Cross, }; editCommand.ToolTip.Text = Resources.SDeleteText; commandColumn.Commands.Add(editCommand); listener.Append("if (command == 'Delete'){"); listener.Append(GetDeleteScript()); listener.Append("}"); }
protected virtual void AddLookButton(StringBuilder listener, CommandColumn commandColumn) { var editCommand = new GridCommand { CommandName = "Look", Icon = Icon.Note, }; editCommand.ToolTip.Text = Resources.SLook; commandColumn.Commands.Add(editCommand); listener.Append("if (command == 'Look'){"); listener.Append(GetLookScript()); listener.Append("}"); }
protected virtual void AddEditButton(StringBuilder listener, CommandColumn commandColumn) { var editCommand = new GridCommand { CommandName = "Edit", Icon = Icon.NoteEdit, }; editCommand.ToolTip.Text = Resources.SEditText; commandColumn.Commands.Add(editCommand); listener.Append("if (command == 'Edit'){"); listener.Append(GetEditScript()); listener.Append("}"); }
private void crearColumnasDeAccion() { if ((agregarColumnaParaBorrar || agregarColumnaParaEditar) && (!Ext.Net.X.IsAjaxRequest)) { CommandColumn column = new CommandColumn(); column.Width = 30; if (agregarColumnaParaBorrar) { if (string.IsNullOrEmpty(manejadorColumnaParaBorrar)) { this.Listeners.Command.Handler += " if (command == 'Borrar') { this.deleteRecord(record); } "; } else { this.Listeners.Command.Handler += string.Format(" if (command == 'Borrar') {{ {0}.call(this, record); }} ", manejadorColumnaParaBorrar); } GridCommand command = new GridCommand(); command.CommandName = "Borrar"; command.Icon = Ext.Net.Icon.Delete; column.Commands.Add(command); } if (agregarColumnaParaEditar) { if (string.IsNullOrEmpty(manejadorColumnaParaEditar)) { throw new ExcepcionAplicacion("El paramatero ManejadorColumnaParaEditar no puede estar vacio si el parametro AgregarColumnaParaEditar es TRUE."); } else { this.Listeners.Command.Handler += string.Format(" if (command == 'Editar') {{ {0}.call(this, record); }} ", manejadorColumnaParaEditar); } GridCommand command = new GridCommand(); command.CommandName = "Editar"; command.Icon = Ext.Net.Icon.TableEdit; column.Commands.Add(command); } this.ColumnModel.Columns.Add(column); } }
private CommandColumn GetViewCommand() { var viewCommand = new CommandColumn { ID = "viewCommand" + ID, Width = 24, Enabled = true }; var editCommand = new GridCommand { CommandName = "View", Icon = Icon.Note }; editCommand.ToolTip.Text = Web.Controls.Properties.Resources.SView; viewCommand.Commands.Add(editCommand); viewCommand.Hidden = true; return(viewCommand); }
private void InitLogic() { this.Listeners.Render.Fn = TasksGrid.SCOPE + ".init"; this.Listeners.Render.Scope = TasksGrid.SCOPE; this.Listeners.AfterRender.Fn = TasksGrid.SCOPE + ".afterRender"; this.Listeners.AfterRender.Scope = TasksGrid.SCOPE; ComponentDirectEvent rowDblClick = this.DirectEvents.ItemDblClick; rowDblClick.Event += RowDblClick_Event; rowDblClick.Before = "return ".ConcatWith(TaskWindow.SCOPE, ".openTask(record.getId());"); rowDblClick.Complete = TasksGrid.SCOPE + ".setIndicator(false);"; rowDblClick.ExtraParams.Add(new Parameter("taskId", "record.getId()", ParameterMode.Raw)); ComponentDirectEvent command = (this.ColumnModel.Columns[0] as CommandColumn).DirectEvents.Command; command.Event += Command_Event; command.Type = DirectEventType.Load; command.ExtraParams.Add(new Parameter("command", "command", ParameterMode.Raw)); command.ExtraParams.Add(new Parameter("taskId", "record.getId()", ParameterMode.Raw)); command.ExtraParams.Add(new Parameter("filter", TasksGrid.SCOPE + ".getFilterValue()", ParameterMode.Raw)); command.ExtraParams.Add(new Parameter("categoryID", TasksGrid.SCOPE + ".getActiveNodeCategory().getId()", ParameterMode.Raw)); command.Before = TasksGrid.SCOPE + ".setIndicator(true);"; command.Complete = TasksGrid.SCOPE + ".setIndicator(false);"; this.store.ReadData += TasksGrid_RefreshData; DropDownField ddf = ((DropDownField)this.ColumnModel.Columns[2].HeaderItems[0]); TreePanel tree = (TreePanel)(ddf.Component[0]); tree.Listeners.ItemClick.Fn = TasksGrid.SCOPE + ".categoryCheckChange"; tree.Listeners.ItemClick.Scope = TasksGrid.SCOPE; ddf.Listeners.Expand.Fn = TasksGrid.SCOPE + ".categoryExpand"; ddf.Listeners.Expand.Scope = TasksGrid.SCOPE; CommandColumn cmdCol = (CommandColumn)this.ColumnModel.Columns[0]; cmdCol.PrepareToolbar.Fn = TasksGrid.SCOPE + ".prepareStatusButton"; RowSelectionModel gridsm = (RowSelectionModel)this.SelectionModel[0]; gridsm.Listeners.SelectionChange.Fn = TasksGrid.SCOPE + ".selectionChange"; gridsm.Listeners.SelectionChange.Scope = TasksGrid.SCOPE; this.Listeners.ItemContextMenu.Fn = TasksGrid.SCOPE + ".onRowContext"; this.Listeners.ItemContextMenu.Scope = TasksGrid.SCOPE; MenuItem mItem = (MenuItem)this.ctxMenu.Items[4]; ComponentDirectEvent click = mItem.DirectEvents.Click; click.Event += DelClick_Event; click.Confirmation.ConfirmRequest = true; click.Confirmation.Message = "Are you sure you want to delete the selected task(s)?"; click.ExtraParams.Add(new Parameter("ids", TasksGrid.SCOPE + ".getSelectedIds()", ParameterMode.Raw)); click.Before = TasksGrid.SCOPE + ".setIndicator(true);"; click.Complete = TasksGrid.SCOPE + ".setIndicator(false);"; mItem = (MenuItem)this.ctxMenu.Items[3]; click = mItem.DirectEvents.Click; click.Event += MarkClick_Event; click.ExtraParams.Add(new Parameter("ids", TasksGrid.SCOPE + ".getSelectedIds()", ParameterMode.Raw)); click.ExtraParams.Add(new Parameter("filter", TasksGrid.SCOPE + ".getFilterValue()", ParameterMode.Raw)); click.ExtraParams.Add(new Parameter("categoryID", TasksGrid.SCOPE + ".getActiveNodeCategory().getId()", ParameterMode.Raw)); click.Before = TasksGrid.SCOPE + ".setIndicator(true);"; click.Complete = TasksGrid.SCOPE + ".setIndicator(false);"; mItem = (MenuItem)this.ctxMenu.Items[0]; click = mItem.DirectEvents.Click; click.Event += OpenClick_Event; click.ExtraParams.Add(new Parameter("ids", TasksGrid.SCOPE + ".getSelectedIds()", ParameterMode.Raw)); click.Before = TasksGrid.SCOPE + ".setIndicator(true);"; click.Complete = TasksGrid.SCOPE + ".setIndicator(false);"; ctxTreeCategory.Listeners.ItemClick.Fn = TasksGrid.SCOPE + ".ctxMoveTasks"; ctxTreeCategory.Listeners.ItemClick.Scope = TasksGrid.SCOPE; }
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); } } } } }
public void SetUp() { theColumn = new CommandColumn<Case, CaseActionModel>(CommandKey.Action); theHarness = new ColumnFillerHarness(); theDto = theHarness.RunColumn<Case>(theColumn, x => { x.SetValue(c => c.Id, _id); }); theColumnModel = theColumn.ToDictionary().Single(); }
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); } } } } }
/// <summary> /// 初始化查询主界面项 /// </summary> /// <param name="grid"></param> public void IniSelectMainGrid(Ext.Net.GridPanel grid) { #region 分页每页数量 var pagesize = uiHelper.Select.MainGrid.PageSize; if (pagesize <= 0) { pagesize = 15; } grid.GetStore().PageSize = pagesize; #endregion string prefix = UiControlNamePrefix.SelectMainGrid; Model model = grid.GetStore().ModelInstance; #region 网格条数信息 int havecount = grid.ColumnModel.Columns.Count; RowNumbererColumn numbercol = new RowNumbererColumn(); numbercol.Width = 40; grid.ColumnModel.Columns.Insert(grid.ColumnModel.Columns.Count - havecount, numbercol); #endregion #region 添加特殊字段 if (uiHelper.UiData.Crud.Primarykey != null && !string.IsNullOrWhiteSpace(uiHelper.UiData.Crud.Primarykey.FieldName)) { IniAddGridColumn(prefix, uiHelper.UiData.Crud.Primarykey.FieldName, havecount, grid); } IniAddGridColumn(prefix, uiHelper.UiData.Crud.DeleteFlag, havecount, grid); #endregion #region 添加设置字段 foreach (GridColumn column in uiHelper.Select.MainGrid.Columns) { ModelField mField = new ModelField(); mField.Name = column.ColumnName; if (column.ColumnType == GridColumnType.Date) { mField.Type = ModelFieldType.Date; } model.Fields.Add(mField); if (column.IsShow) { CellCommandColumn cell = IniGridColumn(prefix, column); grid.ColumnModel.Columns.Insert(grid.ColumnModel.Columns.Count - havecount, cell); } } #endregion #region 更新显示按钮 if (uiHelper.Update.Panel.ParamFields.Count > 0) { return; } int commandcount = 0; if (uiHelper.Select.MainDetail.ParamFields.Count > 0) { commandcount++; } if (uiHelper.Select.DetailGrid.Columns.Count > 0) { commandcount++; } if (commandcount == 0) { return; } CommandColumn commandColumn = new CommandColumn(); commandColumn.ID = "commandColumnShowDetail"; commandColumn.Width = commandcount * 86; commandColumn.Text = "查看"; commandColumn.Align = Alignment.Center; int _command = commandColumn.Commands.Count; if (uiHelper.Select.MainDetail.ParamFields.Count > 0) { GridCommand command = new GridCommand(); command.Icon = Icon.TableColumn; command.Text = "详细信息"; command.CommandName = "ShowFieldsInfo"; commandColumn.Commands.Add(command); commandColumn.Listeners.Command.Fn = "showdetailcommandcolumn_click"; } if (commandColumn.Commands.Count > _command) { commandColumn.Commands.Add(new CommandSeparator()); _command = commandColumn.Commands.Count; } if (uiHelper.Select.DetailGrid.Columns.Count > 0) { GridCommand command = new GridCommand(); command.Icon = Icon.TableColumn; command.Text = "明细信息"; command.CommandName = "ShowDetail"; commandColumn.Commands.Add(command); commandColumn.Listeners.Command.Fn = "showdetailcommandcolumn_click"; } grid.ColumnModel.Columns.Add(commandColumn); #endregion }
protected override void OnInitialized() => CommandColumn.AddCommandButtons(this);