How to Iterate through (array) the below given content to load in two datatables.
How to Iterate through (array) the below given content to load in two datatables.
{
"**OutStandings**": [
[null, null, null, null, null, "Shenzhen Wheeltopn Intl Transportation Co.ltd", "USD", 80.00],
[null, null, null, null, null, "Shenzhen Wheeltopn Intl Transportation Co.ltd", "RMB", 200.00],
[null, null, null, null, null, "Shenzhen Wheeltopn Intl Transportation Co.ltd", "USD", 200.00], null
],
"**OrgBankInfo**": [
[3, "Shenzhen Wheeltopn Intl Transportation Co.ltd", "Luohu", "Bank Of China ", "Shenzhen Dongmen", "744557960885(USD)", null, "BKCHCNBJ45A", null],
[3, "Shenzhen Wheeltopn Intl Transportation Co.ltd", "Luohu", "Bank Of China ", "Shenzhen Dongmen", "749757929717(RMB)", null, "BKCHCNBJ45A", null], null
]
}
I have used Ajax call to a webmethod, where I add two tables to a dataset and return as string (Array) using Json serialize. The string in the question is the string returning to datatables(jquery). I am able to get the string in "response.d" but after that I am finding it difficult to iterate through the string and populate two data tables. I would be really thankful if anyone could sort this out. Thanks.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
I have used Ajax call to a webmethod, where I add two tables to a dataset and return as string (Array) using Json serialize. The string in the question is the string returning to datatables(jquery). I am able to get the string in "response.d" but after that I am finding it difficult to iterate through the string and populate two data tables. I would be really thankful if anyone could sort this out. Thanks.
I'm not sure what data from the above you want to display in the DataTable. Is each entry in
**OutStandings**
a row in the table? If so, useajax.dataSrc
to tell DataTables that fact.Allan
Yes Sir, Each entry in OutStandings is a row in table.
Same is the case for OrgBankInfo.
So I have two tables to populate.
Just need to know how to go about it.
Okay, you can't use DataTables own
ajax
option to populate two different tables form the same Ajax source file. You need to make your own Ajax call ($.ajax
for example) and then userows.add()
to add the rows to the table.Allan