We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use Hirarchical grid for my below db structure. And also help me to use import export of this hirarchical data

Thread ID:

Created:

Updated:

Platform:

Replies:

147915 Sep 27,2019 09:43 AM UTC Oct 3,2019 04:07 PM UTC Angular - EJ 2 5
loading
Tags: Grid
Dinesh D
Asked On September 27, 2019 12:54 PM UTC

My db structure is 

{
    "Category" : "Network",
    "Ipaddress" : "10.202.0.0/16",
    "Subnet" : "10.202.0.0/17",
    "SubCategory" : [ 
        {
            "Category" : "NetworkChild1",
            "Ipaddress" : "12.4.5.5",
            "Subnet" : "122.5.5.5"
        },
       {
            "Category" : "NetworkChild2",
            "Ipaddress" : "124.5.6.8",
            "Subnet" : "122.5.6.5"
        }
    ]
}


"data" is the variable that contains my data.

this.data=tabdata;
            this.childGrid= {
              dataSource:this.data,
              queryString: 'Category',
              columns: [
                  { field: 'Category', headerText: 'Category'},
                  { field: 'Ipaddress', headerText: 'Ipaddress'},
                  { field: 'Subnet', headerText: 'Subnet'},
                 
              ],
          };


Output: When I used "this.data": in dataSource



Output: When i used "this.data.SubCategory" in dataSource



If i give "this.data" in the place of dataSource the parent data is displayed as a child, and if i give "this.data.SubCategory" I cant able to get the sub category data in the table. Can you please take this as a priority issue and help me to resolve it.

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 27, 2019 01:32 PM UTC

Hi Dinesh, 

Greetings from Syncfusion support. 

Based on your query we are can understand that you have problem with rendering hierarchical Grid (Grid with child data). The hierarchical Grid can be rendered by defining the childGrid and the queryString for the childGrid. Here the childGrid describes the grid options and the queryString describes the relation between parent and child grids. Only based on this queryString value, the childGrid is rendered. 

More information on hierarchical binding can be found in the following documentation and online sample links, 


Now in the code block you provided, the queryString value is given as ‘Category’ which would mean that the relation between the parent and child grid is based on the ‘Category’ column value. But in your datasource there is no common value in the ‘Category’ column for the parent and child grid. This is the reason the child grid is not getting displayed. For e.g. – The Category value in parent grid is, ‘Network11’ and if the child data also has the value ‘Network11’ it will be displayed as the child grid since this is the common relation between both the grids. So please modify your datasource based on this as per your requirement for rendering the hierarchical grid. 

We have prepared a sample with the exporting the Grid data to excel. Before this, in the load event of the parent Grid, data for the childGrid has been collected from the parent datasource. Refer  to the demo. 


We could also see you would like to import the data for the Grid. From where you would like to import the data.  

Regards, 
Seeni Sakthi Kumar S 


Dinesh D
Replied On September 30, 2019 11:24 AM UTC

Hi,

Thanks for the Support, I have one more requirement please help me to resolve it. I have a custom add button to add the child element shown below


When i add new child it should reflect in the window without refreshing the screen, but i am getting the child only after refreshing the window.. 

can you help me to solve it

And also help me to to display the number of child in each of the parent

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 30, 2019 11:34 AM UTC

Hi Dinesh,  

We could see you are adding the record to the child Grid and in turn which must update the button in the content. Before proceeding with this requirement, we would like to collect the following details.  

  1. How you are updating the data to the Grid
  2. Complete code example of the Grid
  3. Modify previously attached sample and provide link (if possible)

Regards,  
Seeni Sakthi Kumar S 


Dinesh D
Replied On September 30, 2019 01:43 PM UTC

on clicking the  add icon the following code will execute
//Function called after adding the child data
public addChildInventory(){
  // service to update the child data in db
  this.inventorydataService.addChildInventory(childData , this.rowData.rowData.id).
                subscribe(data => {
                  this.getInventoryData();
                  this.grid.refresh();
                });
}
}


and getInventoryData() function will get all the data values. The code of this function is

if(tabdata.length > 0){
            this.showData = true;
            this.data=tabdata;
            this.parentData=this.data;
            this.childGrid= {
              queryString: 'Key',
              columns: [
                  { field: 'Category', headerText: 'Category'},
                  { field: 'Ipaddress', headerText: 'Ipaddress'},
                  { field: 'Subnet', headerText: 'Subnet'},
                 
              ],
          };   

i am using onload() function to get the child data

public onLoad(): void {
    let child = [];
    (this.grid.dataSource as object[]).forEach((e)=>{
      child = child.concat(e['SubCategory']);
    });
    this.grid.childGrid.dataSource = child;
  }

Balaji Sekar [Syncfusion]
Replied On October 3, 2019 04:07 PM UTC

Hi Dinesh, 
 
Thanks for your patience, 
 
We have validated your query with provided the information and we suspect that you have used the custom binding(InventorydataService) in Grid. Please share the below details to us it will help to implement further 
 
  1. Please share the full code example of Parent Grid. 
  2. Share the child Grid rendering code snippet also. 
  3. If you have customized between Parent and Child Grid, please share code examples. 
  4. Additionally, Share the InventorydataService handling code example. 
 
Regards, 
Balaji Sekar. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon