私は、データテーブルのサーバー側の処理を使用して返されたデータに対して算術演算を実行する方法を理解しようとしていません。クライアント側のデータ型を使用して実行するのは簡単ですが、サーバー側の処理を使用する場合、 。ここに私のコードがあります。Laravel 5.2を使用したデータ・サイドのサーバー側処理での算術計算の実行方法は?
ProductController.php:
public function anyData()
{
$conditionTxt = "Medical and Lab Supplies";
$products = Product::where('category', 'ILIKE', '%'.$conditionTxt.'%')
->orderBy('created_at', 'desc')
->get();
return Datatables::of($products)->make(true);
}
route.php
Route::get('datatables', 'Product\[email protected]');
Route::get('postproductsdata', 'Product\[email protected]');
のjavascript:
$('#table-prod-contents').DataTable({
processing: true,
serverSide: true,
ajax: $.fn.dataTable.pipeline({
url: '{{ url("postproductsdata") }}',
pages: 6000 // number of pages to cache
}),
columns: [
{data: 'id', name: 'id'},
{data: 'category', name: 'category'},
{data: 'pharmaceutical', name: 'pharmaceutical'},
{data: 'description', name: 'description'},
{data: 'type', name: 'type'},
{data: 'unit', name: 'unit'},
{data: 'price', name: 'price'},
{data: 'quantity', name: 'quantity'},
{data: 'created_at', name: 'created_at'},
]
});
HTML:上記のコードを表示
<table id="table-prod-contents" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Category</th>
<th>Product Name</th>
<th>Description</th>
<th>Type</th>
<th>Unit</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Created at</th>
</tr>
</thead>
</table>
、私はその後<th>Total</th>
に表示量に価格を乗算したかったです。どうすればいい?
http://bobby-tables.com/ – Sherif
どのように操作を行いますので、あなたはこのように行うことができます 、あなたはその場でのDataTableに列を追加したいと思われます返されたデータについて – Eli