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

Can we filter the entire grid based on any child grid colum

1 Answer 231 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ujjawal
Top achievements
Rank 1
Ujjawal asked on 23 Feb 2015, 05:06 PM
Hi. i am quite new to telerik controls. i have a hierarchical datagrid where i am using a dataset to bind the grid that has two data table. Orders and OrderProducts.  Order is parent grid and OrderProduct is child grid. Filter work well on child grid but it works on only child rows.

I want to show only those orders in the grid where OrderProducts.productstatus = 'something'. Currently i am using code as below.

            ds.Tables.Add(orders);
            ds.Tables.Add(dtProducts);
            dgOrders.DataSource = ds.Tables[0];
            GridViewTemplate template = new GridViewTemplate();
            template.DataSource = ds.Tables[1];
            dgOrders.MasterTemplate.Templates.Add(template);
            GridViewRelation relation = new GridViewRelation(dgOrders.MasterTemplate);
            relation.ChildTemplate = template;
            relation.RelationName = "OrderProducts";
            relation.ParentColumnNames.Add("OrderNumber");
            relation.ChildColumnNames.Add("OrderNumber");
            dgOrders.Relations.Add(relation);

Any help is really appriciated.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 26 Feb 2015, 12:25 PM
Hello Ujjawal,

Thank you for writing.

In RadGridView the filtering works per template and to achieve the desired functionality you should add a filter descriptor to the child template. For example:
GridViewTemplate template = new GridViewTemplate();
template.DataSource = nwindDataSet.Products;
radGridView1.MasterTemplate.Templates.Add(template);
template.EnableFiltering = true;
FilterDescriptor filter = new FilterDescriptor();
filter.PropertyName = "CategoryID";
filter.Operator = FilterOperator.IsEqualTo;
filter.Value = 2;
template.FilterDescriptors.Add(filter);

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Ujjawal
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or