C# 中具有特定列、聚合和分组的 RadDataGrid
RadDataGrid with specific Columns, Aggregation and Grouping in C#
我在使用具有特定列、聚合和分组的自定义数据网格时遇到问题,它不起作用……好吧,在 C# 中不起作用。
如果在 XAML 中定义,则分组工作 100%,但它对 c# 的命中和失败,主要是失败。
聚合从未起作用。
我基本上是在生成 PivotItems... 这很有效,然后我用一个数据网格填充每个数据透视表,其中定义了特定的列,以及分组和聚合规则。
除了聚合和分组外,PivotItems、DataGrid 和数据的填充都工作得很好。
我什至试过使用XAML模板...也没有用,所以我很茫然。
有人可以提供一些关于我做错了什么的提示吗?
任何帮助或建议将不胜感激。
谢谢
我的代码如下:
private void BuildPivots()
{
if (App.Categories != null)
{
foreach (Categories Category in App.Categories)
{
Home_PivotShell.Items.Add(new PivotItem
{
Header = Category.Name,
Name = Category.Id,
Content = new RadDataGrid
{
AutoGenerateColumns = false,
UserEditMode = DataGridUserEditMode.External,
ItemsSource = App.DataSet.Where(x => x.CategoryId == Category.Id),
GroupDescriptors =
{
new PropertyGroupDescriptor() { PropertyName = "Name", DisplayContent = "Description"}
},
AggregateDescriptors =
{
new PropertyAggregateDescriptor() { PropertyName = "Column1", Function = KnownFunction.Count}
},
Columns =
{
new DataGridTextColumn() { PropertyName = "Name", Header = "Description" },
new DataGridTextColumn() { PropertyName = "Column1" },
new DataGridTextColumn() { PropertyName = "Column2" },
new DataGridTextColumn() { PropertyName = "Column3" },
new DataGridTextColumn() { PropertyName = "Column4" },
new DataGridTextColumn() { PropertyName = "Column5" },
new DataGridTextColumn() { PropertyName = "Column6" },
new DataGridTextColumn() { PropertyName = "Column7" },
}
}
});
}
}
}
数据源(根据要求):
注意:问题不在于数据源,我有几个数据源可以使用,它们都做同样的事情,分组适用于 XAML 而不是 C#。
聚合根本不起作用。
namespace MyUWPApp.DataObjects
{
public class DataSet
{
public string Name { get; set; }
public string Column1 { get; set; }
public string Column2 { get; set; }
public string Column3 { get; set; }
public string Column4 { get; set; }
public string Column5 { get; set; }
public string Column6 { get; set; }
public string Column7 { get; set; }
}
}
我在 Telerik 论坛上 post 编辑了相同的内容并获得了帮助,从而针对我的特定要求生成了一个可行的解决方案。
如果有人在寻找类似的东西,您可以在此处找到 post https://www.telerik.com/forums/raddatagrid-with-specific-columns-aggregation-and-grouping-in-c
我在使用具有特定列、聚合和分组的自定义数据网格时遇到问题,它不起作用……好吧,在 C# 中不起作用。 如果在 XAML 中定义,则分组工作 100%,但它对 c# 的命中和失败,主要是失败。
聚合从未起作用。
我基本上是在生成 PivotItems... 这很有效,然后我用一个数据网格填充每个数据透视表,其中定义了特定的列,以及分组和聚合规则。
除了聚合和分组外,PivotItems、DataGrid 和数据的填充都工作得很好。
我什至试过使用XAML模板...也没有用,所以我很茫然。
有人可以提供一些关于我做错了什么的提示吗?
任何帮助或建议将不胜感激。
谢谢
我的代码如下:
private void BuildPivots()
{
if (App.Categories != null)
{
foreach (Categories Category in App.Categories)
{
Home_PivotShell.Items.Add(new PivotItem
{
Header = Category.Name,
Name = Category.Id,
Content = new RadDataGrid
{
AutoGenerateColumns = false,
UserEditMode = DataGridUserEditMode.External,
ItemsSource = App.DataSet.Where(x => x.CategoryId == Category.Id),
GroupDescriptors =
{
new PropertyGroupDescriptor() { PropertyName = "Name", DisplayContent = "Description"}
},
AggregateDescriptors =
{
new PropertyAggregateDescriptor() { PropertyName = "Column1", Function = KnownFunction.Count}
},
Columns =
{
new DataGridTextColumn() { PropertyName = "Name", Header = "Description" },
new DataGridTextColumn() { PropertyName = "Column1" },
new DataGridTextColumn() { PropertyName = "Column2" },
new DataGridTextColumn() { PropertyName = "Column3" },
new DataGridTextColumn() { PropertyName = "Column4" },
new DataGridTextColumn() { PropertyName = "Column5" },
new DataGridTextColumn() { PropertyName = "Column6" },
new DataGridTextColumn() { PropertyName = "Column7" },
}
}
});
}
}
}
数据源(根据要求):
注意:问题不在于数据源,我有几个数据源可以使用,它们都做同样的事情,分组适用于 XAML 而不是 C#。 聚合根本不起作用。
namespace MyUWPApp.DataObjects
{
public class DataSet
{
public string Name { get; set; }
public string Column1 { get; set; }
public string Column2 { get; set; }
public string Column3 { get; set; }
public string Column4 { get; set; }
public string Column5 { get; set; }
public string Column6 { get; set; }
public string Column7 { get; set; }
}
}
我在 Telerik 论坛上 post 编辑了相同的内容并获得了帮助,从而针对我的特定要求生成了一个可行的解决方案。
如果有人在寻找类似的东西,您可以在此处找到 post https://www.telerik.com/forums/raddatagrid-with-specific-columns-aggregation-and-grouping-in-c