I'm putting together a table with the JS framework DataTables
I process the data via Server-side through JSON
In the first column I would like to display a photo, the name of this photo comes via JSON.
How to do it?
Example of how I'm testing:
<table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Foto</th>
<th>ID Historico</th>
<th>curValor</th>
<th>intid</th>
<th>CurValor</th>
<th>str_CIDADE</th>
<th>Bairro</th>
<th>Opção</th>
</tr>
</thead>
<tbody>
<tr role="row" class="odd">
<th></th>
<th>Foto</th>
<th>ID Historico</th>
<th>curValor</th>
<th>intid</th>
<th>CurValor</th>
<th>str_CIDADE</th>
<th>Bairro</th>
<th></th>
</tr>
</tbody>
</table>
The column I'm going to display the photo is: Photo
The DataTables Javascript is:
/// abreviação
"processing": true,
"serverSide": false,
"ajax": {
"url": "grid3.ashx"
},
columns: [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{
"className": '',
"orderable": false,
"data": null,
"defaultContent": ' <img class="img-thumbnail " src="http://imgteste.wmb.com.br//tb/"style="width:50px;" />'
},
{ data: 'IDHistorico' },
{ data: 'curValor' },
{ data: 'intid' },
{ data: 'curValor' },
{ data: 'str_CIDADE' },
{ data: 'str_BAIRRO' }
///abreviação do código
The line is this: "defaultContent": ''
Summary: I'm trying to retrieve the JSON value and put this in the script that initializes DataTables.net, the field I'm trying is the name of the I tried to create:
var data = table.row( $(this).parents('tr') ).data();
and call as date [8] // 9th json record, but did not work
Uncaught TypeError: Can not read property '8' of undefined