How to relate and load data into datatables from 2 content type using Rest api in SharePoint 2013.

How to relate and load data into datatables from 2 content type using Rest api in SharePoint 2013.

sanjaysp2013sanjaysp2013 Posts: 2Questions: 1Answers: 0

Requirement: There are 2 custom content type available in one of the list of SharePoint 2013 on premise version. 2 content type are related with an empid which can be treated as primary key. I need to load data into datatables from both content type using Rest api.

Example ContentType "Employee" would have fields\columns listed "First Name", "Last Name", "address" etc.
ContentType "HR" would have "position","Salary" etc

Like in https://datatables.net/examples/ajax/deep.html, I need to retrieve all the details and loaded in datatable using Rest api.

Expected Table should show all detail taken from both content type

"First Name", "Last Name", "address" "position","Salary"

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Can you show me an example of the JSON that has been loaded please?

    Allan

  • sanjaysp2013sanjaysp2013 Posts: 2Questions: 1Answers: 0

    Example

    GET /Employee/1

    {
    id: 1,
    fname: "MS",
    lname: "Dhoni",
    address: "India"
    }

    GET /HR/1

    {
    id: 1,
    position: "developer",
    salary: 1000,
    }

    Need to relate 2 content type with id and load all contents in datatable. I can see example in https://datatables.net/examples/ajax/deep.html for nested object dat.
    But I am looking for Rest api code to relate with this id and retrieve data from both content type.

    Thank you so much for looking into this. Hope you understand my situation.

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    It looks to me like you have two Ajax calls per row in the table there. Is that correct? If so, that would really bog down the network connection. You'd be better having a single route GET /Employees/HR or something like that to get all the data you need in a single Ajax call.

    Or have I misunderstood?

    Allan

This discussion has been closed.