Bharat Guru
asked on
Using javascript build custom table from json
How to build table using javascript for below JSON , I want to display Total for each location and RecordType first and then detail for location and recordtype and add extra blank row for each different category
{
"action":"query",
"Warehouse":"NJ",
"records":[
{
"Location":"UK",
"RecordType":"Fruits",
"Qty":16,
"Name":"Total"
},
{
"Location":"UK",
"RecordType":"Grocery",
"Qty":11,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Fruits",
"Qty":5,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Grocery",
"Qty":17,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Fruits",
"Productid":123,
"Qty":5,
"Name":"Apple"
},
{
"Location":"UK",
"RecordType":"Fruits",
"Productid":124,
"Qty":11,
"Name":"Bananna"
},
{
"Location":"US",
"RecordType":"Grocery",
"Productid":223,
"Qty":6,
"Name":"Rice"
},
{
"Location":"UK",
"RecordType":"Grocery",
"Productid":224,
"Qty":11,
"Name":"Beans"
}
]
}
table
Location Name RecordType ProductID, Qty
US ,Total ,Grocery , ,6
US ,Rice ,Grocery ,223 ,6
US ,Total ,Fruits , ,5
US ,Apple ,Fruits ,123 ,5
UK ,Total ,Grocery , ,11
UK ,Beans ,Grocery ,224 ,11
UK ,Total ,Fruits , ,11
UK ,Bananna ,Fruits ,124 ,11
{
"action":"query",
"Warehouse":"NJ",
"records":[
{
"Location":"UK",
"RecordType":"Fruits",
"Qty":16,
"Name":"Total"
},
{
"Location":"UK",
"RecordType":"Grocery",
"Qty":11,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Fruits",
"Qty":5,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Grocery",
"Qty":17,
"Name":"Total"
},
{
"Location":"US",
"RecordType":"Fruits",
"Productid":123,
"Qty":5,
"Name":"Apple"
},
{
"Location":"UK",
"RecordType":"Fruits",
"Productid":124,
"Qty":11,
"Name":"Bananna"
},
{
"Location":"US",
"RecordType":"Grocery",
"Productid":223,
"Qty":6,
"Name":"Rice"
},
{
"Location":"UK",
"RecordType":"Grocery",
"Productid":224,
"Qty":11,
"Name":"Beans"
}
]
}
table
Location Name RecordType ProductID, Qty
US ,Total ,Grocery , ,6
US ,Rice ,Grocery ,223 ,6
US ,Total ,Fruits , ,5
US ,Apple ,Fruits ,123 ,5
UK ,Total ,Grocery , ,11
UK ,Beans ,Grocery ,224 ,11
UK ,Total ,Fruits , ,11
UK ,Bananna ,Fruits ,124 ,11
ASKER
Is there way to do using javascript?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
Thanks
You can have search ,sort,pagination feature in built in that.
https://editor.datatables.net/examples/advanced/deepObjects.html