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

edit column helper class display the button when the User allowed #99

Closed tiegosilveira closed 6 years ago

tiegosilveira commented 9 years ago

display the button when the User is allowed

when if it is equal "211" displays

$this->datatables->set_database('webgpon');//banco $this->datatables->select('llids.id,llid,llids.observacoes,onus.idOLT,login,macAddress,olts.nome') ->from('llids') ->join('onus', 'llids.idONU = onus.id','left')//join ->join('olts', 'onus.idOLT = olts.id','left')//join ->edit_column('altera', '$1', $this->status('id')) ->add_column('deleta', anchor('webgpon/deleta_llid/$1',' <button class="btn btn-primary btn-xs" title="Deleta"> Deleta '), 'id'); echo $this->datatables

->generate("json");

helper class function status($id) { if($id == '211'){ $output = "<a class='btn btn-default btn-xs'
href='altera_llid'".$id."'> Altera "; }else{ $output = "" } return $output; }

marikudo commented 9 years ago

Same Problem here, timelog_date is datetime datatype and I want to change the format.

$this->datatables->select('id,timelog_date') ->edit_column('timelog_date','$1',date("l F j, Y",strtotime('timelog_date'))) ->from('tblname');

foxmedo commented 6 years ago

any one has find a solution for this problem

n1crack commented 6 years ago

Your syntax is wrong. The way you use the library is possible but needs some modifications which I already have done in my repo.

Currently you can try:

$this->datatables->select('id,timelog_date')
->edit_column('TestColumn', '$1 $2  $3', " helperFunction(param1, TestColumn) , id , test(123)" )
->from('tblname');

$1 => helperFunction(param1, TestColumn) $2 => id $3 => test(123)

foxmedo commented 6 years ago

but how can i put in the place of param an array ?

the helperfunction parms must be static i can't use $var ..?

n1crack commented 6 years ago

Well this is the limit of the library. If you need that functionality, I recommend you use https://github.com/n1crack/datatables

Example http://datatables.16mb.com/sqlite_examples/edit/

Code : https://github.com/n1crack/datatables-examples/blob/master/sqlite_examples/edit/ajax.php

foxmedo commented 6 years ago

FYI

i have solve the problem using the json as args