Take a look at the second section in this article Binding to Hierarchical Data Programmatically
Programmatically create hierarchy in telerik radgridview winforms
-
07-03-2022 - |
Pergunta
I am wanting to create a hierarchy in a radgridview that is not data bound. So far, I haven't had any luck on figuring out how to do it.
I figured you could do something like:
Grid.Parent.Rows.Add(new object[] {});
and
Grid.Parent.Child.Rows.Add(new object[] {});
but I've had no such luck. The grid can't be data bound. I have a list of data I will loop through and create the hierarchy.
I need to know how to create parent nodes and child nodes for that parent. I saw the templates and have messed with them, but I can only make it work with a data source.
Can somebody point me in the right direction?
Solução
Outras dicas
// Code for data bind radgridview
void DataBInd()
{
var Source = Results.GetData(FromDate, Todate, drpLedger.Value);
radGridLedgerAccount.DataSource = null;
radGridLedgerAccount.DataSource = Source;
FormatGrid();
BindChildView();
BindBarCharView(Source);
}
//Code for bind childview i.e hierarchy
void BindChildView()
{
if (drpLedger.Value != null)
{
GridViewTemplate childview = new GridViewTemplate();
childview.Caption = "Details";
childview.DataSource = null;
childview.DataSource = Source;
this.radGridLedgerAccount.MasterTemplate.Templates.Add(childview);
FormatChildView(childview);
GridViewRelation relation = new GridViewRelation(this.radGridLedgerAccount.MasterTemplate);
relation.ChildTemplate = childview;
relation.ParentColumnNames.Add("months");
relation.ChildColumnNames.Add("NameOfMonth");
this.radGridLedgerAccount.Relations.Add(relation);
}
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow