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

2 posts, 0 answers
  1. Ujjawal
    Ujjawal avatar
    1 posts
    Member since:
    Feb 2015

    Posted 23 Feb 2015 Link to this post

    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.
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 26 Feb 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top