어떻게 각 행의 데이터 테이블에 단추를 추가 할 수 있습니까? 내 코드로, 내가 옳지 않은 일이있는 것처럼 보입니다.데이터 테이블에 단추 추가 - Jquery
어떻게하면됩니까?
HTML
<table id="users-table" class="table table-hover table-condensed" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Grade</th>
<th>Action</th>
</tr>
</thead>
</table>
JS
$(document).ready(function() {
oTable = $('#users-table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ route('datatable.getpost') }}",
"columns": [
{data: 'name', name: 'name'},
{data: 'description', name: 'description'},
{data: 'no_of_items', name: 'no_of_items'},
],
"aoColumns": [{
{
"mRender": function(data, type, full) {
return '<a class="btn btn-info btn-sm" href=#>' + 'Edit' + '</a>';
}
}
}]
});
});
https://datatables.net/blog/2011-06-19를 확인하십시오. 왜 당신은 mRender를 사용하고 있습니까? –
@VijayRathore, 당신이 준 참조에 대한 버튼을 찾을 수 없습니다. 데이터 테이블을 처음 사용하는 경우 – LearnLaravel
아약스 소스가 버튼에 대해 HTML을 반환하는 경우 Datatable 초기화에 아무 것도 쓸 필요가 없습니다. 확인 아약스 소스 Datatables 여기에 https://www.datatables.net/examples/data_sources/ajax.html –