HTML 5 data-columns
HTML 5 data-columns
Menico
Posts: 2Questions: 1Answers: 0
Hi,
does anyone know how to set the columns via a HTML5 inline tag?
I've tried so many different approaches, but none seems to work.
Currently I have this:
<table id="data-table" class="table table-hover" data-order="" data-page-length="5" data-searching="false" data-length-change="false" data-ajax="GetPalletsGridData"
data-columns='[{ "data": "position" },{ "data": "position" },{ "data": "office" },{ "data": "extn" },{ "data": "salary" }]'>
<thead class="thead-dark">
<tr>
<th width="10px"></th>
<th width="10px">#</th>
<th>Menge</th>
<th>ChargenNr</th>
<th>LieferscheinNr</th>
</tr>
</thead>
</table>
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You apply the options to the
th
elements. See the documentation here.Allan
Argh. Thanks for that easy solution.
Meanwhile I've found the hard one in using the data-column-defs tag on the table itself
data-column-defs='[{"targets":0,"data": null,"defaultContent":"<button class=\"btn btn-outline-danger\" onclick=\"RemovePallet($(this))\"><i class=\"zmdi zmdi-check\"></i></button>"},{"targets":1,"data": "Guid"},{"targets":2,"data": "Amount","type":"num-fmt"},{"targets":3,"data": "ChargeNr"},{"targets":4,"data": "DeliveryNoteNr"}]'
But yours is more elegant and easier on the eyes