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

Will Hierarchy grid works for many to many associated data

Thread ID:

Created:

Updated:

Platform:

Replies:

144550 May 11,2019 09:22 AM UTC May 23,2019 09:30 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Grid
saivikki
Asked On May 11, 2019 09:22 AM UTC

I had many to many associated table sample data will be like the below sample,

I need to show company details as the parent and employee details as the child.

Also i need to edit the employee details, 

I have tried the Hierarchy grid MVC Syncfusion EJS 1, But it the field name provided in querystring need to be in the child data, In Many to Many associated data it won't have. 

Please suggest me any to get it work.


[
  {
    "companyId": "1",
    "name": "ACME, SL",
    "employees": "50",
    "contacts": [
      {
        "employeeId": "1",
        "name": "John",
        "surename": "Smith",
        "department": "Finanzes"
      },
      {
        "employeeId": "2",
        "name": "Alex",
        "surename": "Sanchez",
        "department": "Support"
      },
      {
        "employeeId": "3",
        "name": "Carmen",
        "surename": "Calvo",
        "department": "Finanzes"
      }
    ]
  },
  {
    "companyId": "2",
    "name": "Trendsuper Inc.",
    "employees": "30",
    "contacts": [
      {
        "employeeId": "1",
        "name": "John",
        "surename": "Smith",
        "department": "Finanzes"
      },
      {
        "employeeId": "2",
        "name": "Alex",
        "surename": "Sanchez",
        "department": "Support"
      },
      {
        "employeeId": "3",
        "name": "Carmen",
        "surename": "Calvo",
        "department": "Finanzes"
      },
      {
        "employeeId": "4",
        "name": "John",
        "surename": "Wartong",
        "department": "Labs"
      },
      {
        "employeeId": "5",
        "name": "Quentin",
        "surename": "Tarantino",
        "department": "Support"
      },
      {
        "employeeId": "6",
        "name": "Josh",
        "surename": "Sheldon",
        "department": "IT"
      }
    ]
  },
  {
    "companyId": "3",
    "name": "Cacatua Inc.",
    "employees": "10",
    "contacts": [
       {
        "employeeId": "4",
        "name": "John",
        "surename": "Wartong",
        "department": "Labs"
      },
      {
        "employeeId": "5",
        "name": "Quentin",
        "surename": "Tarantino",
        "department": "Support"
      },
      {
        "employeeId": "6",
        "name": "Josh",
        "surename": "Sheldon",
        "department": "IT"
      },
      {
        "employeeId": "8",
        "name": "Walter",
        "surename": "Distey",
        "department": "Labs"
      },
      {
        "employeeId": "9",
        "name": "Quentin",
        "surename": "Danubio",
        "department": "Support"
      }
    ]
  }
]

Hariharan J V [Syncfusion]
Replied On May 14, 2019 01:19 PM UTC

Hi Saivikki, 
  
Thanks for contacting Syncfusion support, 
  
We have prepared sample based on your requirement. We have achieved your requirement using “Created”, “dataBound”,”detailDataBound” events of the EJ2 Grid. Please find the below code snippet and Sample documentation links for your reference.  
  
@{  
    var ChildGrid1 = new Syncfusion.EJ2.Grids.Grid()  
    {  
        DataSource = ViewBag.empData,  
        QueryString = "EmployeeID",  
        Created ="created",  
        DataBound="dataBound",  
         . . .  
 
  
    };  
        }  
  
<ejs-grid id="PublishedGrid" dataSource="ViewBag.data" childGrid="ChildGrid1" detailDataBound="detailDataBound" allowPaging="true" >  
    . . .  
</ejs-grid>  
<script>  
    var val;  
    var flag = 1;  
    function detailDataBound(args) {  
        val = args.data;    
    }  
    function created(args) {  
        flag = 1;  
    }  
    function dataBound(args) {  
        if (flag) {  
            var pre = [];  
  
           // You can handle many unique columns(querystring) in Child Grid 
            pre.push(new ej.data.Predicate('EmployeeID', 'equal', val["EmployeeID"]));  
            pre.push(new ej.data.Predicate('orderid', 'equal', val["OrderID"]));  
            this.query = new ej.data.Query().where(new ej.data.Predicate.and(pre));  
            this.refresh();  
            flag = 0;  
        }  
      
    }  
</script>  


 
  
                                         https://ej2.syncfusion.com/documentation/api/grid/#databound  
                                         https://ej2.syncfusion.com/documentation/api/grid/#detaildatabound  
  
Please get back to us if you need further assistance.  
  
Regards, 
Hariharan 


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