SVN r413
SVN-Revision: r413
This commit is contained in:
@@ -456,7 +456,7 @@ namespace Lskj.Control
|
||||
{
|
||||
var subField = column.Tag as GridColumnModel;
|
||||
if (subField == null) continue;
|
||||
|
||||
|
||||
string dynamicFieldName = column.FieldName;
|
||||
object updatedValue = updatedRow[dynamicFieldName];
|
||||
|
||||
@@ -6659,6 +6659,7 @@ namespace Lskj.Control
|
||||
/// <param name="originalDataSource"></param>
|
||||
private void BuildDynamicGroupedColumns(BandedGridControlEx bandedGridControlEx, DataTable originalDataSource)
|
||||
{
|
||||
bandedGridControlEx.BandedView.BeginUpdate();
|
||||
// 数据源改变时必须重复执行此逻辑
|
||||
bandedGridControlEx.BandedView.OptionsView.ColumnAutoWidth = false;
|
||||
|
||||
@@ -6728,17 +6729,15 @@ namespace Lskj.Control
|
||||
OptionsColumn = { FixedWidth = true } // <-- 明确设置固定宽度
|
||||
};
|
||||
|
||||
bandedGridControlEx.SetColumnFormat(subColumn, subField);
|
||||
dynamicBand.Columns.Add(subColumn);
|
||||
bandedGridControlEx.BandedView.Columns.Add(subColumn);
|
||||
}
|
||||
}
|
||||
|
||||
bandedGridControlEx.BandedView.EndUpdate();
|
||||
// 构建最终动态数据源
|
||||
DataTable dynamicDataTable = BuildDynamicDataSource(originalDataSource, GroupPrimary, GroupFieldprimary, GroupField, normalColumns, dynamicHeaders);
|
||||
bandedGridControlEx.gridControl.DataSource = dynamicDataTable;
|
||||
|
||||
// 最后再强制刷新布局
|
||||
bandedGridControlEx.BandedView.LayoutChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -6764,13 +6763,20 @@ namespace Lskj.Control
|
||||
|
||||
// 添加主键列
|
||||
if (!dtResult.Columns.Contains(GroupPrimary.FieldName))
|
||||
dtResult.Columns.Add(GroupPrimary.FieldName, typeof(string));
|
||||
{
|
||||
Type dataType = originalDataSource.Columns[GroupPrimary.FieldName].DataType;
|
||||
dtResult.Columns.Add(GroupPrimary.FieldName, dataType);
|
||||
}
|
||||
|
||||
|
||||
// 添加普通列,仅当原数据源存在时才添加
|
||||
foreach (var col in normalColumns)
|
||||
{
|
||||
if (originalDataSource.Columns.Contains(col.FieldName))
|
||||
dtResult.Columns.Add(col.FieldName, typeof(string));
|
||||
{
|
||||
Type dataType = originalDataSource.Columns[col.FieldName].DataType;
|
||||
dtResult.Columns.Add(col.FieldName, dataType);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加动态列 (改为string类型避免异常)
|
||||
@@ -6780,7 +6786,10 @@ namespace Lskj.Control
|
||||
{
|
||||
string dynamicFieldName = $"{header}_{subField.FieldName}";
|
||||
if (!dtResult.Columns.Contains(dynamicFieldName))
|
||||
dtResult.Columns.Add(dynamicFieldName, typeof(string)); // <-- 此处已修改为string
|
||||
{
|
||||
Type dataType = originalDataSource.Columns[subField.FieldName].DataType;
|
||||
dtResult.Columns.Add(dynamicFieldName, dataType); // <-- 此处已修改为string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user