0
イムを使用している間のDataTable内のimgを表示するにはどのように、私は罰金働いていたが、今私は、DataTableの中に表示し、IMGする必要がありますが、いけないが、知っていますどうやって。私はレンダリング文書を読んだが、私はまだ失われている。 表コード:私はlaravel 5.5での作業と私はAJAXでそれを使用してのDataTableとIMを実装アヤックス
<div class="row-fluid margin-body">
<table id="productos" class="table table-hover table-condensed" >
<thead>
<tr>
<th >Id</th>
<th>Producto</th>
<th>Cantidad </th>
<th>img</th>
<th></th>
</tr>
</thead>
</table>
</div>
Ajaxはテーブル内のコンテンツを作成するには:私は私のIMG表示したい場所を
$(document).ready(function(){
listar();
});
var listar = function(){
var table = $('#productos').DataTable({
"processing": true,
"serverSide": true,
"ajax": "ajaxProducto",
"columns":[
{data:'id'},
{data:'nombre'},
{data:'stock'},
{data: 'imagen',
"render": function(data, type, row) {
return '<img src="'+data+'" />';
}},
{defaultContent:
"<a type='button' class='editar btn btn-xs btn-mini btn-primary' data-toggle='modal' data-target='#myModalEditar'>Editar</a><a type='button' class='eliminar btn btn-xs btn-mini btn-danger' >Eliminar</a><a type='button' class='btn btn-xs btn-mini btn-success detalles' data-toggle='modal' data-target='#myModalDetalles'>Detalles</a>"
}
],
"language": idioma_esp
});
}
です
{data: 'imagen',
"render": function(data, type, row) {
return '<img src="img/productos/'+data+'" height="42" width="42"/>'; }}
マイルート:
Route::get('/ajaxProducto', function() {
return datatables()->collection(App\Producto::all())->toJson();
});
あなたがエラーを発見し、質問がまだ値を持っている場合、あなたは答えのセクションでは、ここでの解決策の説明を投稿する必要があります。質問にもう価値がない場合は、それを削除する必要があります。 –