Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi

I want to create a hierarchical data bound grid view with the options of expanding /collapsing rows.I don't want to create a nested grid view.

Suppose a company / Div/ Brand /Sub Brand hierarchy is there so, I want to display the current year and previous year sales for all of them within a table/grid view.

If i collapse company only company name and numbers should be visible and rest other are collapsed. there should a single header for Product/ Sales CY and sales PY.

Below is the structure.

Product         SalesCY       SalesPY
     *Company          20             10
       *Div1           10              4
         Brand1         5              2
         Brand2         5              2
       *Div2           10              6
         Brand3        10              6


Assume * is a button for expand/collapse.

Please help and do let me know in case of any clarification.

Regards,
Prash
Posted
v3

1 solution

 
Share this answer
 
Comments
Prashant Kuamr 30-May-13 9:42am    
There are many solutions both paid/free for nested grid view on the web. But I don't want to implement nested grid view. Within a single grid view 1st Column i would like to use display and control hierarchy and rest column would be applicable for all the items present in the first column.


Regards,
Prashant
The solutions I have provided implements the same thing I guess.
I mean it has a expand/collapse row which will open another detailed gridview.

Don't you need this ?

And I don't get "hierarchy should be controlled from database". An example might help me understand.

Otherwise you need to do some coding on the top of these solutions to implement this.
Prashant Kuamr 30-May-13 10:02am    
hierarchy should be controlled from database". i mean suppose Company is having 2 division right now so in hierarchy 2 divisions and there sales numbers are coming. But suppose after some time one more division is introduced and added in database then code should be dynamic enough to identify and reflect the change. I have sample picture of my requirement. I am new to code project and I dont see anyway to attache a picture with the questions. Btw i have modified my main question, please have a look..hope you will understand.
Yes I understand now... And yes you can't screenshots here in Code Project. You can upload in any site and just add the link here.

Ok. coming to the problem. I can give you solution.

As you are having the information regarding the hierarchy, so you can get that from DataBase whenever you want to load that GridView, right ?

At the time getting the data from the DataBase through procedures or query, try to calculate how much depth is there in Company. I mean how many depts. are there in Company.

Now, you need to create GridViews dynamically as per the count of Depts., makes sense ?

Again under that no. of GridViews for Brands according to their count.

You can follow the codes of Nested GridView and play with that to implement this.
Prashant Kuamr 3-Jun-13 6:36am    
I doubt if this thing can be solved using nested grid view concept. Because we want a single grid view with all the hierarchical data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900