Datatables to support rowspan and colspan from a JSON object.

Datatables to support rowspan and colspan from a JSON object.

mchourishimchourishi 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?

Answers

  • kthorngrenkthorngren Posts: 21,260Questions: 26Answers: 4,932

    It's documented somewhere :smile: 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

This discussion has been closed.