I am trying to working on bootstrap data table in Laravel. My data is load successfully but data table search and pagination is not working.so please help me.
my Html code on page is like that
<table id="example111" class="table table-striped nowrap www" cellspacing="0" width="100%">
<thead>
<tr>
<th class="col-sm-2 col-lg-1">Sr.No.</th>
<th>Department Name</th>
<th class="col-sm-3 col-lg-2">Edit/Delete</th>
</tr>
</thead>
<tbody class="departmentlist" id="departmentlist111">
</tbody>
</table>
my ajax call on page like that
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function() {
table = $('#example111').DataTable( {
paging: false,
} );
table.destroy();
$('#example111').DataTable( {
"serverSide": true,
"ajax":{
"url": "<?= URL::to('show_department')?>",
"dataType": "json",
"type": "post",
"data":{ _token: ""},
"dataSrc": function (e)
{
$("#departmentlist111").html(e);
}
}
} );
} );
my route call on page is like
Route::post('show_department','admin\DepartmentController@show_department');
my controller call
public function show_department()
{
$cartdata ='<tr><td class="col-sm-2 col-lg-1"> 1</td>
<td >South Indian</td>
<td class="col-sm-3 col-lg-2">
<button type="button" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-edit"></i></button>
<button type="button" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-remove"></i></button>
</td></tr>
<tr><td class="col-sm-2 col-lg-1"> 1</td>
<td >South </td>
<td class="col-sm-3 col-lg-2">
<button type="button" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-edit"></i></button>
<button type="button" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-remove"></i></button>
</td></tr>
<tr><td class="col-sm-2 col-lg-1"> 1</td>
<td> Indian</td>
<td class="col-sm-3 col-lg-2">
<button type="button" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-edit"></i></button>
<button type="button" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-remove"></i></button>
</td></tr>
<tr><td class="col-sm-2 col-lg-1"> 1</td>
<td >South Indian</td>
<td class="col-sm-3 col-lg-2">
<button type="button" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-edit"></i></button>
<button type="button" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-remove"></i></button>
</td></tr>';
echo json_encode($cartdata);
}
so please solve my error please.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zSS1iF
via IFTTT
Aucun commentaire:
Enregistrer un commentaire