IgnitedDatatables / Ignited-Datatables

Ignited Datatables is a wrapper class/library based on the native Datatables server-side implementation by Allan Jardine found at http://datatables.net/examples/data_sources/server_side.html for CodeIgniter
285 stars 335 forks source link

add_column does not work #79

Closed ilzat closed 8 years ago

ilzat commented 9 years ago

Hello, i used to:

        $this->datatables
                ->select('objects.id, objects.creator_id, objects.obj_name_short')
                ->from('objects')
                ->join('users','users.id=objects.creator_id','left')
                ->select('surname')
                ->add_column('buttons', 'Hello World');
        echo $this->datatables->generate();

table loading, but does not work when searching error output:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: buttons

Filename: libraries/Datatables.php

Line Number: 322

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at Z:\home\sd2\www\system\core\Exceptions.php:185)

Filename: core/Common.php

Line Number: 440

And My JS code: $(document).ready(function() { $('#datatable').dataTable( { "processing": true, "serverSide": true, "ajax": { "url": "/dashboard/getObjectsByAjax", "type": "POST" }, "columns": [ { "data": "id" },
{ "data": "creator_id" }, { "data": "obj_name_short" }, { "data": "surname" }, { "data": "buttons" } ]

} );

} );

please help me

salfredogonzalez commented 9 years ago

$this->datatables ->select('objects.id, objects.creator_id, objects.obj_name_short') ->from('objects') ->join('users','users.id=objects.creator_id','left') ->select('surname') <---- you are using this one for?? ->add_column('buttons', 'Hello World'); <--- echo $this->datatables->generate();

I am showing an example to use add_column ->add_column('acciones', '$1', "cuentas.id"

maybe this can help you

aazbeltran commented 9 years ago

1 year later... I solved this issue modifying the conditional on L313

if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns))