javascript - How to add div to datatable -
i know whether possible add canvas datatable.
i have installed datatable responsive plugin which, in case column width, clicking button allow see information.
i know whether can add canvas hidden area in order play audio correspond selected row. wish use nice audio player called wavesurfer.js
to able do need learn following:
- how add canvas @ end of hidden area
- how force responsive table not display canvas in case table has enough space
- the canvas has fill hidden div 100%
picture of trying achieve (each row audio file)
please see following information
<div id="demo"> <div id="waveform"> <div class="progress progress-striped active" id="progress-bar" style="display: none;"> <div class="progress-bar progress-bar-info" style="width: 100%;"></div> </div> <wave style="display: block; position: relative; -webkit-user-select: none; height: 128px; overflow-x: auto; overflow-y: hidden;"><canvas width="870" height="128" style="position: absolute; z-index: 1; top: 0px; bottom: 0px; width: 870px;"></canvas><wave style="position: absolute; z-index: 2; top: 0px; bottom: 0px; overflow: hidden; width: 0px; display: block; box-sizing: border-box; border-right-style: solid; border-right-width: 1px; border-right-color: navy;"><canvas width="870" height="128" style="width: 870px;"></canvas></wave></wave> </div> </div>
use format() method in child rows example provided in comments. can modify format return div can create canvas using wavesurfer.js
function format(d) { return '<div class="player"></div>'; } var table = $('#example').datatable({ "columns": [{ "classname": 'details-control', "orderable": false, "data": null, "defaultcontent": '+' }, { "data": "name" }, { "data": "position" }, { "data": "id" }] }); $('#example tbody').on('click', 'td.details-control', function() { var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isshown()) { // row open - close row.child.hide(); tr.removeclass('shown'); } else { // open row row.child(format(row.data())).show(); tr.addclass('shown'); } });
Comments
Post a Comment