Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel datatable addColumn not working

1. have the same number of <th> in html. 
  <th>ID</th>
  <th>Name</th>
  <th>Action</th>

2. in laravel controller
  return Datatables::of($users)
            ->addColumn('action', function ($user) {
                return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
            })
            ->make(true);}


3. javascript
$('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'https://datatables.yajrabox.com/eloquent/add-edit-remove-column-data',
        columns: [
            {data: 'id', name: 'id'},
            {data: 'name', name: 'name'},
            {data: 'action', name: 'action', orderable: false, searchable: false}
        ]
  
    });
Comment

PREVIOUS NEXT
Code Example
Php :: laravel 8 with jetstream 
Php :: php url exists valid 
Php :: toastr in php 
Php :: Laravel Migration - Update Enum Options 
Php :: laravel redirect action 
Php :: php array serialize 
Php :: php list *files 
Php :: PDO encode result recordset to utf8 
Php :: laravel packages 
Php :: acf wordpress loop through and display blog posts order by date and type 
Php :: how to set optional third parameter in routes of codeigniter 
Php :: laravel multiple copy record 
Php :: woocommerce update_status 
Php :: php replace string 
Php :: how to save multiple records in database using laravel 
Php :: array shift php 
Php :: laravel reading log file 
Php :: laravel rule unique where 
Php :: inverse hyperbolic cosine php 
Php :: php docker offical apache 
Php :: laravel get namespace 
Php :: ::latest() 
Php :: if file is not selected in file input type php 
Php :: php max int 
Php :: simple pagination in php 
Php :: call jquery function in php code 
Php :: show uploaded image in php 
Php :: laravel one command for model table and controller 
Php :: Clear any previous error php 
Php :: IP Authorization php code 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =