我使用下拉列表尝试了组 Telerik 网格
分组方法源码如下
try
{
this.grd.MasterTableView.GroupByExpressions.Clear();//clear all group expressions
grd.MasterTableView.GroupsDefaultExpanded = false;
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
gridGroupByField = new GridGroupByField();
if (cboGroupByItem1.SelectedValue != "0")
{
gridGroupByField.FieldName = cboGroupByItem1.SelectedValue;
gridGroupByField.HeaderText = cboGroupByItem1.SelectedItem.Text;
expression.SelectFields.Add(gridGroupByField);
}
if (cboGroupByItem2.SelectedValue != "0")
{
gridGroupByField.FieldName = cboGroupByItem2.SelectedValue;
gridGroupByField.HeaderText = cboGroupByItem2.SelectedItem.Text;
expression.SelectFields.Add(gridGroupByField);
}
grd.MasterTableView.GroupByExpressions.Add(expression);
}
catch (Exception ex)
{
label1.Text = ex.ToString();
}
finally
{
grd.Rebind();
}
当网格重新绑定方法时,它会产生波纹管错误
将关系添加到 DataRelationCollection 时出错。请确保您已正确配置表达式 - GroupByFields 和 SelectFields 都是必需的!
如何解决这个问题呢 ?