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

Hiding Tables when no data at Hierarchical Grid with serveral tables at a single level

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
santhosh
Top achievements
Rank 2
santhosh asked on 20 Mar 2009, 10:54 AM
Hi,

I am using herarchial grid with 4 levles and i am using multiple tables at the 2nd level, My problem is i want to hide one of the two table based on data that has if there are no data in that table then i need to hide that table i.e

MainTalbe
    -- Detail Table1
            -multiple table 1(data is there)
            -multiple table 2(no data) ------need to hide this.
    ---Detail Table1
            -multiple table 1(no data)
            -multiple table 2(data is there) -------need to hide this.


This i my scenario, now i want to hide the table with no data at 3rd level here some childs may have data and some childs may not have data, kindly advise how to do this it all at the single level.

Regards,

Santhosh

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 24 Mar 2009, 03:32 PM
Hello Santhosh,

To attain the functionality you are searching for, you need to get all NestedViewItems and hide all of them which do not contain any data recursively.

Here is code snippet showing how to achieve this:
public void Page_PreRenderComplete(object sender, EventArgs e) 
       { 
           HideExpandColumnRecursive(RadGrid1.MasterTableView); 
       } 
       public void HideExpandColumnRecursive(GridTableView tableView) 
       { 
           GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); 
           foreach (GridNestedViewItem nestedViewItem in nestedViewItems) 
           { 
               foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) 
               { 
                   if (nestedView.Items.Count == 0) 
                   { 
                       nestedViewItem.Visible = false
                   } 
 
                   if (nestedView.HasDetailTables) 
                   { 
                       HideExpandColumnRecursive(nestedView); 
                   } 
               } 
           } 
       } 

You can use the directions from this help topic for further reference.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
santhosh
Top achievements
Rank 2
answered on 25 Mar 2009, 10:38 AM
Hi,

I tried the way you have specified, but its not working. I think you are not clear about my problem, let me explain
I am using hierarchical gird
MainTable-------------------(this is the main table)
    -- Detail Table1------------------------1st level
            -multiple table 1(data is there)                                       ------------2nd level
            -multiple table 2(no data) ------need to hide this.           -------------2ndlevel
    ---Detail Table1-------------------------1st level
            -multiple table 1(no data)-------need to hide this            ------------2nd level
            -multiple table 2(data is there) .                                       ------------2nd level

What i am getting is at the first level first childs multipletable1 data is getting displayed for 5 rows and another 5 blank rows are getting displayed which is of the multipletable2 where no data is there(this is the table which i want to hide) The same way its happening in the second child of first level.

Kinldy advice.

Regards,

Santhosh
Tags
Grid
Asked by
santhosh
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
santhosh
Top achievements
Rank 2
Share this question
or