This is a migrated thread and some comments may be shown as answers.

Radgrid Hierarchy Problem

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
yoomee kwon
Top achievements
Rank 1
yoomee kwon asked on 13 Sep 2012, 02:42 PM
Hi, I haven a question using the filterexpression.

I have a situation where I have to use two fields as a key.  

Parent Id can be used for two cases, bakery and grocery ( kind)
same Child id can be used for both bakery and grocery as well.

The hierarchy i want to see is following:

123 bakery
-  456 bakery
123  grocery
- 456 grocery

However, this is how it shows up now.
123 bakery
456 bakery
456 grocery
123  grocery
456 bakery
456 grocery

Is there any way that I can add filter so I can check "kind" column when I create the hierarchy?

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 18 Sep 2012, 01:14 PM
Hi,

You could achieve your scenario by modifying your datasource if needed and creating additional conditions in RadGrid DetailTableDataBind as it is shown below. Additionally, you could take a look at the attached project in order to implement the desired functionality.
protected void RadGrid1_DetailTableDataBind(object sender, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("Kind");
    if (e.DetailTableView.ParentItem.GetDataKeyValue("Kind").ToString().Contains("bakery"))
    {
        table.Rows.Add("456 bakery");
    }
    else if (e.DetailTableView.ParentItem.GetDataKeyValue("Kind").ToString().Contains("grocery"))
    {
        table.Rows.Add("456 grocery");
    }
    e.DetailTableView.DataSource = table;
}

Greetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
yoomee kwon
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or