Initialize a table within a table

Initialize a table within a table

tnanektnanek Posts: 8Questions: 0Answers: 0
edited January 2013 in General
Okay, I'm trying to initialize a second DataTable on a page that already has one (literally one inside the other).

The outter one works as expected, and is in var example1.

The inner is to be initialized on clicking one of the rows of the outer one, and shown in the area created by the fnOpen() function, I also have any already open rows closing on click, so I know the id is not in use on the page, and I can usurp the example2 variable.

Anyhow, regardless of the data, I'm unable to get it to display. When I see the source of the page, I see DataTables has acted on it, but no rows were created.

And I know this code is executing because just prior to this, I open the item of the parent table and add the structure (thead) of this table where it should be; plus a few console.log's are outputting information too

[code]
var obj, example2;
// ...
obj = [
{
'FIELD_1': 'test',
'FIELD_2': 'exam',
'FIELD_3': 'This is but an exam',
'FIELD_4': 'No need to worry'
},
{
'FIELD_1': 'test 2',
'FIELD_2': 'exam 2',
'FIELD_3': 'This is but a second exam',
'FIELD_4': 'No need to worry again'
}
];
example2 = $('#example2').dataTable({
'bPaginate': false,
'bFilter': false,
'sScrollY': '200px',
'oLanguage': {
'sEmptyTable': 'No data found'
},
'aaSorting': [[3,'desc']],
'aaData': obj,
'aoColumns': [
{'mData': 'FIELD_1'},
{'mData': 'FIELD_2'},
{'mData': 'FIELD_3'},
{'mData': 'FIELD_4'},
]
});
[/code]

Replies

  • tnanektnanek Posts: 8Questions: 0Answers: 0
    Sigh, dumb mistake, I didn't have an id on the table I was adding, though it seemed to have some DT things around it, they may have been from the parent item. So disregard this, because I got it working.
This discussion has been closed.