javascript - Laravel DataTable how to render data as input -


i'm trying render piece of data i'm getting ajax call numeric input field laravel datatables , server-side processing.

i getting data expected rendering doesn't happen , don't see rows appear.

<div class="row col-md-12 table-responsive">                     <table class="table table-bordered table-striped" id="no-cost-price-table">                         <thead>                         <tr>                             <th>{{ trans('labels.backend.table.store.best_profit_margin.product') }}</th>                             <th>{{ trans('labels.backend.table.store.best_profit_margin.price_excl') }}</th>                             <th>{{ trans('labels.backend.table.store.best_profit_margin.cost_price') }}</th>                         </tr>                         </thead>                     </table>                 </div>                 <!-- /.col --> 

this table i'm trying populate.

$('#no-cost-price-table').datatable({         'processing': true,         'serverside': true,         'ajax': '{!! route('admin.ajax.dashboard.no_cost_price.get') !!}',         'responsive': true,         'paging': true,         'lengthchange': true,         'searching': false,         'ordering': false,         'info': true,         'autowidth': false,         'language': {             'emptytable': '{{  trans('strings.backend.stores.tables.no_products') }}',             'lengthmenu': '{{ trans('strings.backend.stores.tables.menu') }}',             'info': '{{ trans('strings.backend.stores.tables.info') }}',         },         'columns': [             {data: 'name', name: 'name'},             {data: 'price_excl', name: 'price_excl'},             {                 data: 'data', name: 'cost_price_excl',                 render: function (data, type, row) {                     console.log(data);                     return '<input class="form-control" name="updatecostprice" type="number" step="0.01" @input="updatecostprice($event, ' + data.id + ')" value="' + data.cost_price + '"  >';                 }             },         ],     }); 

this script run.

/**  * route names prefixed 'admin.ajax'.  */ route::group(['middleware' => 'access.routeisxhr', 'prefix' => 'ajax', 'as' => 'ajax.'], function () {  route::get('dashboard/get/nocostpricetable/', 'ajax\dashboardcontroller@getnocostpricedata')     ->name('dashboard.no_cost_price.get');  }); 

this route file

public function getnocostpricedata(request $request) {     $store = access()->getcurrentstore();     $website = $store->website();     $limit = $this->getlimit($store);      $data = \db::table('store_data_products')->select('price_excl', 'cost_price_excl', 'name', 'store_data_product_id')->where([         ['cost_price_excl', '=', 0],         ['website_id', '=', $website->website_id],     ])->when($limit, function ($query) {         return $query->limit(100);     })->get();      $data = json_decode(json_encode($data), true);     if (! empty($data)) {         ($i = 0; $i < count($data); $i++) {             $data[$i]['price_excl'] = number::money($data[$i]['price_excl']);             $data[$i]['data'] = ['id' => $data[$i]['store_data_product_id'], 'cost_price' => $data[$i]['cost_price_excl']];         }     }      return datatables::of($data)->make(true); } 

and function being called ajax call.

i getting rows ajax call table still empty.

i hope able point out mistakes might have made , fix this.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -