SVN r758
SVN-Revision: r758
This commit is contained in:
@@ -93,6 +93,7 @@ namespace Lskj.Control
|
||||
//this.gcMain.OptionsFind.AlwaysVisible = true;
|
||||
}
|
||||
|
||||
|
||||
private void TreeListObj_CustomDrawNodeIndicator(object sender, CustomDrawNodeIndicatorEventArgs e)
|
||||
{
|
||||
try
|
||||
@@ -1915,9 +1916,15 @@ namespace Lskj.Control
|
||||
/// <param name="selectRowHandler">if set to <c>true</c> [select row handler].</param>
|
||||
public override void SetGridViewDataSource(DataTable table, bool selectRowHandler = true)
|
||||
{
|
||||
if (this.ColumnList == null || this.ColumnList.Count == 0)
|
||||
{
|
||||
this.gcMain.Bands.Clear();
|
||||
this.gcMain.Columns.Clear();
|
||||
}
|
||||
TreeListNode lastNode = this.TreeListObj.FocusedNode;
|
||||
GetTreeExpanded();
|
||||
this.gcMain.DataSource = table;
|
||||
this.SetAutoColumns();
|
||||
//根据记录展开对应节点
|
||||
foreach (TreeListNode treeListNode in treeListNodes)
|
||||
{
|
||||
@@ -1932,16 +1939,20 @@ namespace Lskj.Control
|
||||
public override int SetGridViewDataSource(SqlDataAdapter adapter, bool selectRowHandler = true)
|
||||
{
|
||||
if (adapter == null) return 0;
|
||||
if (this.ColumnList == null || this.ColumnList.Count == 0)
|
||||
{
|
||||
this.gcMain.Bands.Clear();
|
||||
this.gcMain.Columns.Clear();
|
||||
}
|
||||
TreeListNode lastNode = this.TreeListObj.FocusedNode;
|
||||
this.AdapterObj = adapter;
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, "SetGridViewDataSource");
|
||||
|
||||
SqlCommandBuilder cb = new SqlCommandBuilder(this.AdapterObj);
|
||||
|
||||
GetTreeExpanded();
|
||||
this.gcMain.DataSource = dataSet.Tables[0];
|
||||
|
||||
this.SetAutoColumns();
|
||||
//根据记录展开对应节点
|
||||
foreach (TreeListNode treeListNode in treeListNodes)
|
||||
{
|
||||
@@ -1957,6 +1968,10 @@ namespace Lskj.Control
|
||||
{
|
||||
this.gcMain.ExpandToLevel(0);
|
||||
}
|
||||
else if ((Expansion + "").Equals("3"))
|
||||
{
|
||||
this.gcMain.CollapseAll();
|
||||
}
|
||||
if (selectRowHandler)
|
||||
{
|
||||
this.TreeListObj.FocusedNode = lastNode;
|
||||
@@ -1966,6 +1981,175 @@ namespace Lskj.Control
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置动态列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-06-03 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
protected virtual void SetAutoColumns()
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isShowFooter = false;
|
||||
if (this.ColumnList == null || this.ColumnList.Count == 0)
|
||||
{
|
||||
this.SuspendLayout();
|
||||
this.ResumeLayout();
|
||||
List<String> bandEmptyRows = new List<String>();
|
||||
List<String> bandFields = new List<String>();
|
||||
DataRow dr = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
||||
bool isEdit = false;//是否可操作
|
||||
if (dr != null && !(this.Model is DynamicReportModel))
|
||||
{
|
||||
ModuleModel SysModel = new ModuleModel(dr);
|
||||
isEdit = SysModel.CanEdit;
|
||||
}
|
||||
if (this is TreeBandedGridControlEx)
|
||||
{
|
||||
|
||||
TreeListBand gridBandEmpty = new TreeListBand();
|
||||
foreach (TreeListColumn item in gcMain.Columns)
|
||||
{
|
||||
//if (item.FieldName.StartsWith("|")) item.FieldName = item.FieldName.Replace("|","");
|
||||
if (item.FieldName.Contains("|"))
|
||||
{
|
||||
int index = item.FieldName.LastIndexOf("|");
|
||||
string bandField = item.FieldName.Substring(0, index);
|
||||
if (!bandFields.Contains(bandField)) bandFields.Add(bandField);
|
||||
}
|
||||
else
|
||||
{
|
||||
bandEmptyRows.Add(item.FieldName);
|
||||
}
|
||||
}
|
||||
foreach (string bandName in bandFields)
|
||||
{
|
||||
TreeListBand gridBand = new TreeListBand();
|
||||
gridBand.Caption = bandName;
|
||||
gridBand.AppearanceHeader.Options.UseFont = true;
|
||||
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
|
||||
gridBand.AppearanceHeader.Options.UseTextOptions = true;
|
||||
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
|
||||
gcMain.Bands.AddRange(new TreeListBand[] { gridBand });
|
||||
//bandFields += "|" + item.BandFields;
|
||||
}
|
||||
if (bandEmptyRows != null && bandEmptyRows.Count() > 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);
|
||||
}
|
||||
gcMain.BeginUpdate();
|
||||
// 创建列
|
||||
for (int i = 0; i < gcMain.Columns.Count; i++)
|
||||
{
|
||||
TreeListColumn col = gcMain.Columns[i];
|
||||
int vsNum = 0; bool isNum = false; string FieldName = col.FieldName; string bandTitle = string.Empty;
|
||||
col.VisibleIndex = i;
|
||||
if (col.FieldName.Contains("|"))
|
||||
{
|
||||
string[] colSplit = col.FieldName.Split('|');
|
||||
if (colSplit.Length >= 2)
|
||||
{
|
||||
FieldName = colSplit[1];
|
||||
bandTitle = colSplit[0];
|
||||
}
|
||||
}
|
||||
if (col.VisibleIndex == 0)
|
||||
{
|
||||
isShowFooter = true;
|
||||
|
||||
gcMain.OptionsView.ShowSummaryFooter = true;
|
||||
col.AllNodesSummary = true;
|
||||
col.SummaryFooter = SummaryItemType.Count;
|
||||
col.SummaryFooterStrFormat = "合计:{0:#,###}行";
|
||||
|
||||
}
|
||||
if (FieldName.Contains("_"))
|
||||
{
|
||||
string[] colparame = FieldName.Split('_');
|
||||
if (colparame.Length >= 2)
|
||||
{
|
||||
FieldName = colparame[0];
|
||||
isNum = Int32.TryParse(colparame[1], out vsNum);
|
||||
if (vsNum == 0)
|
||||
col.Visible = false;
|
||||
if (colparame.Length > 2)
|
||||
{
|
||||
bool visible = "1".Equals(colparame[2]);
|
||||
// 设置底部合计
|
||||
if (visible)
|
||||
{
|
||||
isShowFooter = true;
|
||||
|
||||
gcMain.OptionsView.ShowSummaryFooter = true;
|
||||
col.AllNodesSummary = true;
|
||||
col.SummaryFooter = DevExpress.XtraTreeList.SummaryItemType.Sum;
|
||||
col.SummaryFooterStrFormat = "{0:}";
|
||||
}
|
||||
if (colparame.Length > 3)
|
||||
{
|
||||
string dataFormat = colparame[3];
|
||||
if (!string.IsNullOrWhiteSpace(dataFormat))
|
||||
{
|
||||
col.Format.FormatType = FormatType.Custom;
|
||||
col.Format.FormatString = dataFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(bandTitle))
|
||||
{
|
||||
// 绑定了多表头显示
|
||||
TreeListBand gridBand = gcMain.Bands.Cast<TreeListBand>().FirstOrDefault(x => x.Caption == bandTitle);
|
||||
if (gridBand != null)
|
||||
{
|
||||
gridBand.Columns.Add(col);//
|
||||
TreeListBandColumnCollection gcc = gridBand.Columns;
|
||||
}
|
||||
gcMain.Columns.Add(col);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 未绑定多表头则直接显示
|
||||
if (bandEmptyRows != null && bandEmptyRows.Contains(col.FieldName))
|
||||
{
|
||||
gridBandEmpty.Columns.Add(col);
|
||||
}
|
||||
gcMain.Columns.Add(col);
|
||||
}
|
||||
if (isNum) col.Width = vsNum;
|
||||
|
||||
col.OptionsColumn.AllowEdit = isEdit;
|
||||
//col.FieldName = FieldName;
|
||||
//col.Name = FieldName;
|
||||
col.Caption = FieldName;
|
||||
col.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
|
||||
col.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;
|
||||
col.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
|
||||
//gcMain.OptionsView.ShowFooter = isShowFooter;
|
||||
}
|
||||
gcMain.EndUpdate();
|
||||
//this.bandedGridView.DataSource = bandedGridView.DataSource as DataTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 记录展开的节点
|
||||
@@ -2523,8 +2707,16 @@ namespace Lskj.Control
|
||||
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs"/> instance containing the event data.</param>
|
||||
private void OnCustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e)
|
||||
{
|
||||
if (e.Node == this.gcMain.FocusedNode)
|
||||
e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a");
|
||||
try
|
||||
{
|
||||
if (e.Node == this.gcMain.FocusedNode)
|
||||
e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 粘贴功能
|
||||
|
||||
Reference in New Issue
Block a user