Closed renmura closed 3 years ago
can you show your javascript code?
what php and codeigniter version do you use?
can you show your javascript code?
what php and codeigniter version do you use?
I'm using php 8.0 and codeigniter 4.1.3 here is my javascript :
$('#table').DataTable({ processing: true, serverSide: true, ajax:{ url: 'user/datatable', method: 'POST' }, columnDefs: [ { targets: 0, orderable: false}, //first column is not orderable. ], sDom: "<'row'<'col-md-4'l><'col-md-4'B><'col-md-4'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>", buttons: [ 'copy', { extend: 'excel', orientation: 'landscape', pageSize: 'A4', }, { extend: 'pdf', orientation: 'landscape', pageSize: 'A4', }, { extend: 'print', orientation: 'landscape', pageSize: 'A4', } ] });
try define your datatable option with columns like example. also if using numbering also set parameter addNumbering('number');
in your case maybe like this
columns: [
{data: 'number'},
{data: 'id_role'},
{data: 'role_name'},
]
try define your datatable option with columns like example. also if using numbering also set parameter addNumbering('number');
in your case maybe like this
columns: [ {data: 'number'}, {data: 'id_role'}, {data: 'role_name'}, ]
Great, it works.. I think the error from before is come from the backend side not in the frontend side.. Thank you very much
Hi, I read the documentation here about join query. I have two simple table to join with. But there is an error says that
Undefined property: stdClass::$role.id_role
Somehow the library recognize the table name as the column name, including the period symbol. In the documentation says that theoffices.officeCode
is fine.Here is my code :
User table structure : id_user* id_role** name
Role table structure : id_role* role_name
Controller :
$builder = $db->table('user')
->select('name, role.id_role, role.role_name')
->join('role', 'role.id_role = user.id_role');
return DataTable::of($builder)
->addNumbering()
->toJson(true);
Error :
ErrorException
Undefined property: stdClass::$role.id_role
VENDORPATH/hermawan/codeigniter4-datatables/src/DataTableQuery.php at line 101