I have a simple DataTable()
in a golden layout container:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script type="text/javascript" src="../../static/js/jq.min.js"></script>
<script type="text/javascript" src="../../static/js/gl.min.js"></script>
<script type="text/javascript" src="../../static/js/dt.js"></script>
<link type="text/css" rel="stylesheet" href="../../static/css/gl-base.css" />
<link type="text/css" rel="stylesheet" href="../../static/css/gl-dark-theme.css" />
<link rel="stylesheet" type="text/css" href="../../static/css/dt.css"/>
<link rel="stylesheet" type="text/css" href="../../static/css/dt-custom.css"/>
</head>
<body>
<script>
function getTable() {
return "<table id=\"testTable\" class=\"testTable\" cellspacing=\"0\">\n" +
" <thead>\n" +
" <tr>\n" +
" <th>Name</th>\n" +
" <th>Position</th>\n" +
" <th>Office</th>\n" +
" <th>Age</th>\n" +
" <th>Start date</th>\n" +
" <th>Salary</th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td>Tiger Nixon</td>\n" +
" <td>System Architect</td>\n" +
" <td>Edinburgh</td>\n" +
" <td>61</td>\n" +
" <td>2011/04/25</td>\n" +
" <td>$320,800</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>Garrett Winters</td>\n" +
" <td>Accountant</td>\n" +
" <td>Tokyo</td>\n" +
" <td>63</td>\n" +
" <td>2011/07/25</td>\n" +
" <td>$170,750</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>Ashton Cox</td>\n" +
" <td>Junior Technical Author</td>\n" +
" <td>San Francisco</td>\n" +
" <td>66</td>\n" +
" <td>2009/01/12</td>\n" +
" <td>$86,000</td>\n" +
" </tr>\n" +
" </tbody>\n" +
" </table>"
}
var config = {
content: [{
type: 'row',
content: [
{
type:'component',
componentName: 'testComponent'
}]
}]
};
var myLayout = new GoldenLayout( config );
myLayout.registerComponent( 'testComponent', function(container, state){
container.getElement().append(getTable());
});
myLayout.init();</script>
<script type="text/javascript">
$(document).ready(function() {
$('#testTable').DataTable();
} );
</script>
</body>
</html>
The table displays correctly with the DataTable()
styling when opened in a browser, however when I pop out the widow the table loses all styling and reverts to the basic HTML.
From reading the GL docs I think I need to subscribe to the open event on the new GL pop out container and call table.DataTable()
there but as I am just now learning JavaScript and jQuery etc. I am unsure where I would do this?