Datatables to support rowspan and colspan from a JSON object.
Datatables to support rowspan and colspan from a JSON object.
mchourishi
Posts: 1Questions: 1Answers: 0
I want to create a table that supports both row and column spans.
The table should be created dynamically from JSON object.
Below is the object.
var myArr = [{
"Id": 1,
"Name": 'Ken',
"Age": '30',
"Hobbies": [{
'HobbyId': 1,
'HobbyName': 'Swimming'
}, {
'HobbyId': 2,
'HobbyName': 'Reading'
}],
"Skills": [{
'SkillId': 1,
'SkillName': 'PHP'
}, {
'SkillId': 2,
'SkillName': 'MySQL'
}],
"Language": [{
'LangId': 2,
'LangName': 'English'
}, {
'LangId': 3,
'LangName': 'Chinese'
}]
},
{
"Id": 2,
"Name": 'Mike',
"Age": '20',
"Hobbies": [],
"Skills": [],
"Language": []
},
{
"Id": 3,
"Name": 'Charlie',
"Age": '25',
"Hobbies": [{
'HobbyId': 5,
'HobbyName': 'Dance'
}, {
'HobbyId': 6,
'HobbyName': 'Sing'
}, {
'HobbyId': 7,
'HobbyName': 'Writing'
}],
"Skills": [],
"Language": [{
'LangId': 7,
'LangName': 'English'
}]
}
];
And it should look like the table attached in the image.
Can we do that with data table?
This discussion has been closed.
Answers
It's documented somewhere but rowspans and colspans are not supported in the table rows although you can use them in the header as long as the last table header does not have colspans.
Kevin