SVN r381
SVN-Revision: r381
This commit is contained in:
@@ -48,6 +48,10 @@ namespace Lskj.Control
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class TreeBandedGridControlEx : TreeGridControlEx
|
public partial class TreeBandedGridControlEx : TreeGridControlEx
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取模块配置
|
||||||
|
/// </summary>
|
||||||
|
public ModuleModel moduleModel;
|
||||||
public TreeList TreeListObj { get { return gcMain; } }
|
public TreeList TreeListObj { get { return gcMain; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -278,12 +282,6 @@ namespace Lskj.Control
|
|||||||
this.gcMain.Bands.Clear();
|
this.gcMain.Bands.Clear();
|
||||||
this.gcMain.Columns.Clear();
|
this.gcMain.Columns.Clear();
|
||||||
this.AddBandColumns(table);
|
this.AddBandColumns(table);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DataTable customTable = this.gcMain.GetCustomColumnByDatabase(this.CustomColumKey);
|
|
||||||
this.SetCustomColumns(customTable);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -301,6 +299,7 @@ namespace Lskj.Control
|
|||||||
protected void AddBandColumns(DataTable table, bool readOnly = true)
|
protected void AddBandColumns(DataTable table, bool readOnly = true)
|
||||||
{
|
{
|
||||||
if (table == null) return;
|
if (table == null) return;
|
||||||
|
this.InitGridColumsTab = table;
|
||||||
this.mControlList.Clear();
|
this.mControlList.Clear();
|
||||||
List<String> bandFieldstr = new List<String>();
|
List<String> bandFieldstr = new List<String>();
|
||||||
string bandFields = string.Empty;
|
string bandFields = string.Empty;
|
||||||
@@ -309,239 +308,135 @@ namespace Lskj.Control
|
|||||||
GridColumnModel model = new GridColumnModel(item);
|
GridColumnModel model = new GridColumnModel(item);
|
||||||
this.ColumnList.Add(model);
|
this.ColumnList.Add(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<int, TreeListBand> gridBandEmptyDic = new Dictionary<int, TreeListBand>();
|
Dictionary<int, TreeListBand> gridBandEmptyDic = new Dictionary<int, TreeListBand>();
|
||||||
TreeListBand gridBandEmpty = new TreeListBand();
|
TreeListBand gridBandEmpty = new TreeListBand();
|
||||||
//this.bandedGridView.OptionsView.ColumnHeaderAutoHeight = DefaultBoolean.True;
|
|
||||||
// 添加Band 列
|
|
||||||
GridColumnModel[] bandRows = this.ColumnList.Where(x => !string.IsNullOrEmpty(x.BandFields)).ToArray();
|
GridColumnModel[] bandRows = this.ColumnList.Where(x => !string.IsNullOrEmpty(x.BandFields)).ToArray();
|
||||||
GridColumnModel[] AutobandRows = this.ColumnList.Where(x => x.FieldText.Contains("|")).ToArray();
|
GridColumnModel[] AutobandRows = this.ColumnList.Where(x => x.FieldText.Contains("|")).ToArray();
|
||||||
GridColumnModel[] bandEmptyRows = null;
|
GridColumnModel[] bandEmptyRows = null;
|
||||||
if (true)//this.moduleModel != null && this.moduleModel.BandSequentialMode
|
|
||||||
|
if (this.moduleModel != null && this.moduleModel.TreeAutoMultiHeader==1)
|
||||||
{
|
{
|
||||||
bandEmptyRows = AutobandRows.Length > 0 ? this.ColumnList.Where(x => !x.FieldText.Contains("|") && x.Width > 0).ToArray() : this.ColumnList.Where(x => bandRows.Select(n => n.BandFields.Equals(x.FieldName)).Count() == 0 && x.Width > 0).ToArray();
|
bandEmptyRows = AutobandRows.Length > 0
|
||||||
|
? this.ColumnList.Where(x => !x.FieldText.Contains("|") && x.Width > 0).ToArray()
|
||||||
|
: this.ColumnList.Where(x => bandRows.Select(n => n.BandFields.Equals(x.FieldName)).Count() == 0 && x.Width > 0).ToArray();
|
||||||
|
|
||||||
foreach (GridColumnModel columnModel in this.ColumnList)
|
foreach (GridColumnModel columnModel in this.ColumnList)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(columnModel.BandFields))
|
string bandTitle = !string.IsNullOrEmpty(columnModel.BandFields)
|
||||||
|
? columnModel.BandTitle
|
||||||
|
: columnModel.FieldText.Contains("|")
|
||||||
|
? columnModel.FieldText.Substring(0, columnModel.FieldText.LastIndexOf("|"))
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
|
TreeListBand gridBand = null;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(bandTitle))
|
||||||
{
|
{
|
||||||
TreeListBand gridBand = new TreeListBand();
|
|
||||||
gridBand.Caption = columnModel.BandTitle;
|
|
||||||
gridBand.AppearanceHeader.Options.UseFont = true;
|
|
||||||
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
|
||||||
if (columnModel.BandTitle.Contains("\\r\\n"))
|
|
||||||
{
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
|
||||||
gridBand.Caption = columnModel.BandTitle.Replace("\\r\\n", " ");
|
|
||||||
gridBand.RowCount = 2;
|
|
||||||
}
|
|
||||||
saveGridBands.Add(gridBand);
|
|
||||||
gcMain.Bands.AddRange(new TreeListBand[] { gridBand });
|
|
||||||
gridBandEmpty = new TreeListBand();//切换时重置空列
|
|
||||||
}
|
|
||||||
else if (columnModel.FieldText.Contains("|"))
|
|
||||||
{
|
|
||||||
if (bandRows.Length == 0 && AutobandRows.Length > 0)
|
|
||||||
{
|
|
||||||
TreeListBand gridBand = new TreeListBand();
|
|
||||||
int index = columnModel.FieldText.LastIndexOf("|");
|
|
||||||
string bandTitle = columnModel.FieldText.Substring(0, index);
|
|
||||||
string bandField = columnModel.FieldText.Substring(index + 1, columnModel.FieldText.Length - index - 1);
|
|
||||||
if (bandFieldstr.Contains(bandTitle)) continue;
|
if (bandFieldstr.Contains(bandTitle)) continue;
|
||||||
bandFieldstr.Add(bandTitle);
|
bandFieldstr.Add(bandTitle);
|
||||||
gridBand.Caption = bandTitle;
|
|
||||||
|
gridBand = new TreeListBand();
|
||||||
|
gridBand.Caption = bandTitle.Replace("\\r\\n", " ");
|
||||||
gridBand.AppearanceHeader.Options.UseFont = true;
|
gridBand.AppearanceHeader.Options.UseFont = true;
|
||||||
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
||||||
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
||||||
|
|
||||||
if (bandTitle.Contains("\\r\\n"))
|
if (bandTitle.Contains("\\r\\n"))
|
||||||
{
|
{
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
||||||
gridBand.Caption = bandTitle.Replace("\\r\\n", " ");
|
|
||||||
gridBand.RowCount = 2;
|
gridBand.RowCount = 2;
|
||||||
}
|
}
|
||||||
//gridBand.RowCount = 10;
|
|
||||||
//gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
|
||||||
saveGridBands.Add(gridBand);
|
saveGridBands.Add(gridBand);
|
||||||
gcMain.Bands.AddRange(new TreeListBand[] { gridBand });
|
this.gcMain.Bands.Add(gridBand);
|
||||||
gridBandEmpty = new TreeListBand();//切换时重置空列
|
gridBandEmpty = new TreeListBand();
|
||||||
}
|
}
|
||||||
}
|
else if ((AutobandRows.Length > 0 && !columnModel.FieldText.Contains("|") && columnModel.Width > 0)
|
||||||
else if ((AutobandRows.Length > 0 && !columnModel.FieldText.Contains("|") && columnModel.Width > 0) || (AutobandRows.Length <= 0 && bandRows.Select(n => n.BandFields.Equals(columnModel.FieldName)).Count() == 0 && columnModel.Width > 0))
|
|| (AutobandRows.Length <= 0 && bandRows.Select(n => n.BandFields.Equals(columnModel.FieldName)).Count() == 0 && columnModel.Width > 0))
|
||||||
{
|
{
|
||||||
// 空白列
|
|
||||||
gridBandEmpty.Caption = "";
|
gridBandEmpty.Caption = "";
|
||||||
gridBandEmpty.AppearanceHeader.Options.UseFont = true;
|
gridBandEmpty.AppearanceHeader.Options.UseFont = true;
|
||||||
gridBandEmpty.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
gridBandEmpty.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
||||||
gridBandEmpty.AppearanceHeader.Options.UseTextOptions = true;
|
gridBandEmpty.AppearanceHeader.Options.UseTextOptions = true;
|
||||||
gridBandEmpty.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
gridBandEmpty.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
||||||
|
|
||||||
if (!gcMain.Bands.Contains(gridBandEmpty))
|
if (!gcMain.Bands.Contains(gridBandEmpty))
|
||||||
{
|
|
||||||
gcMain.Bands.Add(gridBandEmpty);
|
gcMain.Bands.Add(gridBandEmpty);
|
||||||
}
|
|
||||||
gridBandEmptyDic.Add(this.ColumnList.IndexOf(columnModel), gridBandEmpty);
|
gridBandEmptyDic.Add(this.ColumnList.IndexOf(columnModel), gridBandEmpty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (GridColumnModel item in bandRows)
|
|
||||||
{
|
|
||||||
TreeListBand gridBand = new TreeListBand();
|
|
||||||
gridBand.Caption = item.BandTitle;
|
|
||||||
gridBand.AppearanceHeader.Options.UseFont = true;
|
|
||||||
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
|
||||||
if (item.BandTitle.Contains("\\r\\n"))
|
|
||||||
{
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
|
||||||
gridBand.Caption = item.BandTitle.Replace("\\r\\n", " ");
|
|
||||||
gridBand.RowCount = 2;
|
|
||||||
}
|
|
||||||
saveGridBands.Add(gridBand);
|
|
||||||
gcMain.Bands.AddRange(new TreeListBand[] { gridBand });
|
|
||||||
|
|
||||||
bandFields += "|" + item.BandFields;
|
|
||||||
}
|
|
||||||
if (bandRows.Length == 0 && AutobandRows.Length > 0)
|
|
||||||
{
|
|
||||||
foreach (GridColumnModel item in AutobandRows)
|
|
||||||
{
|
|
||||||
TreeListBand gridBand = new TreeListBand();
|
|
||||||
int index = item.FieldText.LastIndexOf("|");
|
|
||||||
string bandTitle = item.FieldText.Substring(0, index);
|
|
||||||
string bandField = item.FieldText.Substring(index + 1, item.FieldText.Length - index - 1);
|
|
||||||
if (bandFieldstr.Contains(bandTitle)) continue;
|
|
||||||
bandFieldstr.Add(bandTitle);
|
|
||||||
gridBand.Caption = bandTitle;
|
|
||||||
gridBand.AppearanceHeader.Options.UseFont = true;
|
|
||||||
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
|
||||||
if (bandTitle.Contains("\\r\\n"))
|
|
||||||
{
|
|
||||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
|
||||||
gridBand.Caption = bandTitle.Replace("\\r\\n", " ");
|
|
||||||
gridBand.RowCount = 2;
|
|
||||||
}
|
|
||||||
//gridBand.RowCount = 10;
|
|
||||||
//gridBand.AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap;
|
|
||||||
|
|
||||||
saveGridBands.Add(gridBand);
|
|
||||||
gcMain.Bands.AddRange(new TreeListBand[] { gridBand });
|
|
||||||
bandFields += "|" + bandField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bandFields = bandFields + "|";
|
|
||||||
// 检查是否包含空白列
|
|
||||||
bandEmptyRows = AutobandRows.Length > 0 ? this.ColumnList.Where(x => !x.FieldText.Contains("|") && x.Width > 0).ToArray() : this.ColumnList.Where(x => !bandFields.Contains("|" + x.FieldName + "|") && x.Width > 0).ToArray();
|
|
||||||
if (bandEmptyRows != null && bandEmptyRows.Length > 0)
|
|
||||||
{
|
|
||||||
// 空白列
|
|
||||||
gridBandEmpty.Caption = "";
|
|
||||||
gridBandEmpty.AppearanceHeader.Options.UseFont = true;
|
|
||||||
gridBandEmpty.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
|
||||||
gridBandEmpty.AppearanceHeader.Options.UseTextOptions = true;
|
|
||||||
gridBandEmpty.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
|
||||||
gcMain.Bands.Insert(0, gridBandEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 创建列
|
// 创建列
|
||||||
for (int i = 0; i < this.ColumnList.Count; i++)
|
for (int i = 0; i < this.ColumnList.Count; i++)
|
||||||
{
|
{
|
||||||
GridColumnModel model = this.ColumnList[i];
|
GridColumnModel model = this.ColumnList[i];
|
||||||
//if (model.Width == 0 || !model.Visible) continue;
|
|
||||||
int startIndex = model.FieldText.Contains("|") ? model.FieldText.LastIndexOf("|") : 0;
|
int startIndex = model.FieldText.Contains("|") ? model.FieldText.LastIndexOf("|") : 0;
|
||||||
string FieldText = startIndex > 0 ? model.FieldText.Substring(startIndex + 1, model.FieldText.Length - startIndex - 1) : model.FieldText;
|
string FieldText = startIndex > 0 ? model.FieldText.Substring(startIndex + 1) : model.FieldText;
|
||||||
|
|
||||||
TreeListColumn gridColumn = new TreeListColumn();
|
TreeListColumn gridColumn = new TreeListColumn();
|
||||||
|
gridColumn.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
|
||||||
|
|
||||||
string bandTitle = startIndex > 0 ? model.FieldText.Substring(0, startIndex) : HasBand(model.FieldName, bandRows);
|
string bandTitle = startIndex > 0 ? model.FieldText.Substring(0, startIndex) : HasBand(model.FieldName, bandRows);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(bandTitle))
|
TreeListBand gridBand = gcMain.Bands.Cast<TreeListBand>().FirstOrDefault(x => x.Caption == bandTitle);
|
||||||
{
|
|
||||||
// 绑定了多表头显示
|
|
||||||
TreeListBand gridBand = this.gcMain.Bands.Cast<TreeListBand>().FirstOrDefault(x => x.Caption == bandTitle);
|
|
||||||
if (gridBand != null)
|
if (gridBand != null)
|
||||||
{
|
{
|
||||||
gridBand.Columns.Add(gridColumn);
|
gridBand.Columns.Add(gridColumn);
|
||||||
if (saveGridBandColumn.ContainsKey(gridBand))
|
if (saveGridBandColumn.ContainsKey(gridBand))
|
||||||
{
|
saveGridBandColumn[gridBand] += model.FieldName + "^";
|
||||||
saveGridBandColumn[gridBand] = saveGridBandColumn[gridBand] + model.FieldName + "^";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
saveGridBandColumn.Add(gridBand, model.FieldName + "^");
|
saveGridBandColumn.Add(gridBand, model.FieldName + "^");
|
||||||
}
|
}
|
||||||
|
else if (bandEmptyRows != null && bandEmptyRows.Contains(model))
|
||||||
}
|
|
||||||
gcMain.Columns.Add(gridColumn);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 未绑定多表头则直接显示
|
|
||||||
if (bandEmptyRows != null && bandEmptyRows.Contains(model))
|
|
||||||
{
|
|
||||||
if (true)//this.moduleModel != null && this.moduleModel.BandSequentialMode
|
|
||||||
{
|
{
|
||||||
|
if (this.moduleModel != null && this.moduleModel.BandSequentialMode)
|
||||||
gridBandEmptyDic[this.ColumnList.IndexOf(model)].Columns.Add(gridColumn);
|
gridBandEmptyDic[this.ColumnList.IndexOf(model)].Columns.Add(gridColumn);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gridBandEmpty.Columns.Add(gridColumn);
|
gridBandEmpty.Columns.Add(gridColumn);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
gcMain.Columns.Add(gridColumn);
|
gcMain.Columns.Add(gridColumn);
|
||||||
}
|
|
||||||
//gridColumn.OptionsColumn.AllowMerge = model.CanMerge ? DefaultBoolean.True : DefaultBoolean.False;
|
|
||||||
//if (model != null && model.CanMerge)
|
|
||||||
// gcMain.OptionsView.AllowCellMerge = true;//若有合并列则设置表合并,合并后无法多选
|
|
||||||
|
|
||||||
gridColumn.FieldName = model.FieldName;
|
gridColumn.FieldName = model.FieldName;
|
||||||
gridColumn.Name = model.FieldName;
|
|
||||||
gridColumn.VisibleIndex = i;
|
|
||||||
gridColumn.Caption = FieldText;
|
gridColumn.Caption = FieldText;
|
||||||
gridColumn.Width = model.Width;
|
gridColumn.Width = model.Width;
|
||||||
gridColumn.Visible = model.Visible;
|
gridColumn.Visible = model.Visible;
|
||||||
gridColumn.OptionsColumn.AllowEdit = !readOnly && model.Edit;
|
gridColumn.OptionsColumn.AllowEdit = !readOnly && model.Edit;
|
||||||
gridColumn.Tag = model;
|
gridColumn.Tag = model;
|
||||||
gridColumn.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;
|
gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
||||||
gridColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
|
|
||||||
if (EnabledChangeColor)
|
if (model.DataAlignment > 0)
|
||||||
{
|
{
|
||||||
if (!model.Edit)
|
gridColumn.AppearanceCell.Options.UseTextOptions = true;
|
||||||
{
|
gridColumn.AppearanceCell.TextOptions.HAlignment = model.DataAlignment == 1
|
||||||
gridColumn.AppearanceHeader.Options.UseForeColor = true;
|
? HorzAlignment.Center
|
||||||
gridColumn.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(HeaderColor);
|
: HorzAlignment.Far;
|
||||||
}
|
|
||||||
else if (model.CanNull)
|
|
||||||
{
|
|
||||||
gridColumn.AppearanceHeader.Options.UseForeColor = true;
|
|
||||||
gridColumn.AppearanceHeader.ForeColor = RequiredForceColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.SetColumnFormat(gridColumn, model);
|
SetColumnFormat(gridColumn, model);
|
||||||
this.SetColumnSumming(gridColumn, model);
|
SetColumnSumming(gridColumn, model);
|
||||||
this.InitEditColumns(gridColumn, model);
|
InitEditColumns(gridColumn, model);
|
||||||
|
|
||||||
|
if (model.RepeatedVerification)
|
||||||
|
this.RepeatedVerificationNames.Add(model.FieldName);
|
||||||
}
|
}
|
||||||
// 加载数据源
|
SetCustomColumns();
|
||||||
//BindDataSource();
|
|
||||||
DataTable customTable = this.gcMain.GetCustomColumnByDatabase(this.CustomColumKey);
|
|
||||||
this.SetCustomColumns(customTable);
|
|
||||||
// 延迟加载数据源
|
|
||||||
this.mLoading = false;
|
this.mLoading = false;
|
||||||
this.mTimer.Tick += new EventHandler(mTimerTick);
|
this.mTimer.Tick += mTimerTick;
|
||||||
this.mTimer.Start();
|
this.mTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:是否为多表头</para>
|
/// <para>说明:是否为多表头</para>
|
||||||
/// <para>创建人:龚宇超</para>
|
/// <para>创建人:龚宇超</para>
|
||||||
@@ -1050,8 +945,12 @@ namespace Lskj.Control
|
|||||||
mutilLookUp.ValueMember = model.FieldType == ControlType.LabMultiSelectValue ||
|
mutilLookUp.ValueMember = model.FieldType == ControlType.LabMultiSelectValue ||
|
||||||
model.FieldType == ControlType.LabMultiSelectValueParam ? model.ValueMember : model.TextMember;
|
model.FieldType == ControlType.LabMultiSelectValueParam ? model.ValueMember : model.TextMember;
|
||||||
mutilLookUp.Tag = model;
|
mutilLookUp.Tag = model;
|
||||||
|
|
||||||
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
||||||
|
btnEdit.Disposed += (s, e) =>
|
||||||
|
{
|
||||||
|
mutilLookUp?.Dispose();
|
||||||
|
mutilLookUp = null;
|
||||||
|
};
|
||||||
btnEdit.NullText = "";
|
btnEdit.NullText = "";
|
||||||
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
||||||
btnEdit.AllowNullInput = DefaultBoolean.False;
|
btnEdit.AllowNullInput = DefaultBoolean.False;
|
||||||
@@ -1449,8 +1348,6 @@ namespace Lskj.Control
|
|||||||
this.gcMain.Bands.Clear();
|
this.gcMain.Bands.Clear();
|
||||||
this.gcMain.Columns.Clear();
|
this.gcMain.Columns.Clear();
|
||||||
this.AddBandColumns(table, false);
|
this.AddBandColumns(table, false);
|
||||||
DataTable customTable = this.gcMain.GetCustomColumnByDatabase(this.CustomColumKey);
|
|
||||||
this.SetCustomColumns(customTable);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:设置编辑列</para>
|
/// <para>说明:设置编辑列</para>
|
||||||
@@ -1730,51 +1627,101 @@ namespace Lskj.Control
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:设置树表格自定义列</para>
|
/// <para>说明:设置自定义列(适配TreeList)</para>
|
||||||
/// <para>创建人:王一帆</para>
|
/// <para>创建人:龚宇超</para>
|
||||||
/// <para>创建日期:2019-11-14 </para>
|
/// <para>创建日期:2018-02-01 </para>
|
||||||
/// <para>修改人:</para>
|
/// <para>修改人:</para>
|
||||||
/// <para>修改日期:</para>
|
/// <para>修改日期:</para>
|
||||||
/// <para>修改备注:</para>
|
/// <para>修改备注:</para>
|
||||||
/// <para>版本:1.0</para>
|
/// <para>版本:1.0</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void SetCustomColumns(DataTable customTable, bool isInit = true)
|
/// <summary>
|
||||||
|
/// 设置自定义列(适配TreeList,精准修正OwnerBand不存在的问题)
|
||||||
|
/// </summary>
|
||||||
|
/// <summary>
|
||||||
|
/// <para>说明:设置自定义列(适配TreeList)</para>
|
||||||
|
/// <para>创建人:龚宇超</para>
|
||||||
|
/// <para>创建日期:2018-02-01 </para>
|
||||||
|
/// <para>修改人:</para>
|
||||||
|
/// <para>修改日期:</para>
|
||||||
|
/// <para>修改备注:</para>
|
||||||
|
/// <para>版本:1.0</para>
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void SetCustomColumns(bool isInit = true)
|
||||||
{
|
{
|
||||||
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
if (string.IsNullOrEmpty(this.CustomColumKey) || !BaseImpl.HasExistsTable(ResourceKeys.SettingTableName)) return;
|
||||||
if (!dataCaches.GetValue(this, "HasExistsSettingTable", out bool hasExistsSettingTable))
|
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, "FieldText"))
|
||||||
{
|
{
|
||||||
hasExistsSettingTable = BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
|
BaseImpl.ExecSqlValue("alter table " + ResourceKeys.SettingTableName + " add FieldText varchar(100)");
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(this.CustomColumKey) || !hasExistsSettingTable) return;
|
|
||||||
|
DataTable customTable = this.gcMain.GetCustomColumnByDatabase(this.CustomColumKey);
|
||||||
if (customTable != null && customTable.Rows.Count > 0)
|
if (customTable != null && customTable.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
|
int MaxIndex = customTable.Columns.Count;
|
||||||
foreach (DataRow rowItem in customTable.Rows)
|
foreach (DataRow rowItem in customTable.Rows)
|
||||||
{
|
{
|
||||||
string fieldName = rowItem["fieldName"] + "";
|
string fieldName = rowItem["fieldName"] + "";
|
||||||
|
string FieldText = rowItem["FieldText"] + "";
|
||||||
int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]);
|
int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]);
|
||||||
int index = Convert.ToInt32(rowItem["orderid"]);
|
int index = Convert.ToInt32(rowItem["orderid"]);
|
||||||
bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0;
|
bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0;
|
||||||
bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase);
|
bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
GridColumnModel column = this.ColumnList.Find(x => x.FieldName == fieldName);
|
GridColumnModel column = this.ColumnList.Find(x => x.FieldName == fieldName);
|
||||||
TreeListColumn gridColumn = this.gcMain.Columns.ColumnByName(fieldName);
|
TreeListColumn treeColumn = this.gcMain.Columns[fieldName];
|
||||||
if (column != null && gridColumn != null && gridColumn.Visible && gridColumn.Width > 0)
|
|
||||||
|
if (column != null && !string.IsNullOrEmpty(fieldName) && treeColumn != null && treeColumn.Visible && treeColumn.Width > 0)
|
||||||
{
|
{
|
||||||
TreeListColumn colObj = this.gcMain.Columns[fieldName];
|
TreeListBand treeBand = gcMain.Bands.Cast<TreeListBand>().FirstOrDefault(b => b.Columns.Contains(treeColumn));
|
||||||
colObj.VisibleIndex = index;
|
|
||||||
colObj.Width = fieldWidth;
|
if (index >= 0 && index <= this.gcMain.Columns.Count - 1)
|
||||||
colObj.Visible = visible;
|
{
|
||||||
colObj.Fixed = isFix ? FixedStyle.Left : FixedStyle.None;
|
this.gcMain.Columns.Remove(treeColumn);
|
||||||
|
TreeListColumn newColumn = this.gcMain.Columns.Insert(index);
|
||||||
|
|
||||||
|
//重新设置列属性
|
||||||
|
newColumn.FieldName = fieldName;
|
||||||
|
newColumn.Caption = FieldText;
|
||||||
|
newColumn.Width = fieldWidth;
|
||||||
|
newColumn.VisibleIndex = index;
|
||||||
|
newColumn.Visible = visible;
|
||||||
|
newColumn.Tag = column;
|
||||||
|
newColumn.OptionsColumn.AllowEdit = treeColumn.OptionsColumn.AllowEdit;
|
||||||
|
|
||||||
|
if (treeBand != null)
|
||||||
|
{
|
||||||
|
treeBand.Columns.Add(newColumn);
|
||||||
|
treeBand.Fixed = isFix ? FixedStyle.Left : FixedStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FieldText.Contains("|") && isFix)
|
||||||
|
{
|
||||||
|
FixLeftItemClick(newColumn, new EventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (TreeListColumn col in this.gcMain.Columns)
|
||||||
|
{
|
||||||
|
DataRow a = customTable.Rows.Cast<DataRow>().FirstOrDefault(x => col.Name.Equals(x["fieldName"] + "", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (a == null)
|
||||||
|
{
|
||||||
|
bool visible = col.Visible;
|
||||||
|
col.VisibleIndex = MaxIndex;
|
||||||
|
MaxIndex += 1;
|
||||||
|
col.Visible = visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isInit)
|
if (!isInit)
|
||||||
{
|
{
|
||||||
// 非初始化,假如未配置则初始化到系统配置
|
|
||||||
for (int i = 0; i < this.ColumnList.Count; i++)
|
for (int i = 0; i < this.ColumnList.Count; i++)
|
||||||
{
|
{
|
||||||
GridColumnModel column = this.ColumnList[i];
|
GridColumnModel column = this.ColumnList[i];
|
||||||
if (this.gcMain.Columns.ColumnByName(column.FieldName) != null)
|
if (this.gcMain.Columns[column.FieldName] != null)
|
||||||
{
|
{
|
||||||
TreeListColumn colObj = this.gcMain.Columns[column.FieldName];
|
TreeListColumn colObj = this.gcMain.Columns[column.FieldName];
|
||||||
colObj.VisibleIndex = i;
|
colObj.VisibleIndex = i;
|
||||||
@@ -1785,6 +1732,10 @@ namespace Lskj.Control
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:监听树表格键盘事件</para>
|
/// <para>说明:监听树表格键盘事件</para>
|
||||||
/// <para>创建人:王一帆</para>
|
/// <para>创建人:王一帆</para>
|
||||||
|
|||||||
Reference in New Issue
Block a user