/// <summary> /// 构建网格列 DateColumn /// </summary> /// <param name="prefix"></param> /// <param name="column"></param> /// <returns></returns> private CellCommandColumn IniGridColumn(string prefix, GridColumn column) { Caption caption = uiHelper.UiData.GetCaption(column.Caption, column.ColumnName); CellCommandColumn result = null; result = IniGridDateColumn(column); if (result == null) { result = new Column(); } result.ID = prefix + column.ColumnName; result.DataIndex = column.ColumnName; if (column.Locked) { result.Locked = column.Locked; } if (column.Flex > 0) { result.Flex = column.Flex; } else { if (column.Width > 0) { result.Width = column.Width; } else { result.Flex = 1; } } result.Text = caption.Value; return(result); }
/// <summary> /// 初始化自动增加的隐藏项(主键项或删除标识项) /// </summary> /// <param name="prefix"></param> /// <param name="key"></param> /// <param name="havecount"></param> /// <param name="grid"></param> private void IniAddGridColumn(string prefix, string key, int havecount, Ext.Net.GridPanel grid) { Model model = grid.GetStore().ModelInstance; if (!string.IsNullOrWhiteSpace(key)) { bool isExist = false; foreach (GridColumn column in uiHelper.Select.MainGrid.Columns) { if (key.Equals(column.ColumnName, StringComparison.CurrentCultureIgnoreCase)) { column.ColumnName = key; isExist = true; break; } } if (!isExist) { GridColumn column = new GridColumn(); column.Caption = key; column.ColumnName = key; column.IsShow = false; ModelField mField = new ModelField(); mField.Name = column.ColumnName; model.Fields.Add(mField); if (column.IsShow) { CellCommandColumn cell = IniGridColumn(prefix, column); grid.ColumnModel.Columns.Insert(grid.ColumnModel.Columns.Count - havecount, cell); } } } }
/// <summary> /// 初始化查询 明细列表 /// </summary> /// <param name="grid"></param> public void IniSelectDetailGrid(Ext.Net.GridPanel grid) { #region 分页每页数量 var pagesize = uiHelper.Select.DetailGrid.PageSize; if (pagesize <= 0) { pagesize = 15; } grid.GetStore().PageSize = pagesize; #endregion string prefix = UiControlNamePrefix.SelectDetailGrid; 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 添加设置字段 foreach (GridColumn column in uiHelper.Select.DetailGrid.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 }
/// <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 }