mysql - JQuery Datatables + Codeigniter (Static cols) -


i using codeigniter jquery datatables present data mysql database realtime updates via ajax/json requests. not original developer of code that's why not being able solve problem guess.

what have table 26 columns, not of them yet populated seems of them there straight database. how piece of code json_table function looks:

$this->load->model('aircraft_model'); $this->load->model('nats_model');  $acolumns = array('flightsts', 'tblorder', 'callsign', 'destination', 'nat', 'selcal', 'cldfl', 'cldmach', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'flightid'); $stable = 'naecs_aircraft'; 

$stable seems mysql table correct, $acolumns seems fields mysql table naecs_aircraft. that's correct , works in second last column, before flightid want populate button. in second last collumn want have button.

how it?

regards, maciej.

@edit1

this whole function within controller ajax.php:

public function json_table(){     $this->access->requires(access_user);     $this->load->model('aircraft_model');     $this->load->model('nats_model');      $acolumns = array('flightsts', 'tblorder', 'callsign', 'destination', 'nat', 'selcal', 'cldfl', 'cldmach', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'flightid');     $stable = 'naecs_aircraft';      $idisplaystart = $this->input->get_post('idisplaystart', true);     $idisplaylength = $this->input->get_post('idisplaylength', true);     $isortcol_0 = $this->input->get_post('isortcol_0', true);     $isortingcols = $this->input->get_post('isortingcols', true);     $ssearch = $this->input->get_post('ssearch', true);     $secho = $this->input->get_post('secho', true);      if(isset($isortcol_0))     {         for($i=0; $i<intval($isortingcols); $i++)         {             $isortcol = $this->input->get_post('isortcol_'.$i, true);             $bsortable = $this->input->get_post('bsortable_'.intval($isortcol), true);             $ssortdir = $this->input->get_post('ssortdir_'.$i, true);              if($bsortable == 'true')             {                 if ($acolumns[$isortcol] != ' '){                     $this->aircraft_model->json_table_sort($acolumns, $isortcol, $ssortdir);                 }             }         }     }      if(isset($ssearch) && !empty($ssearch))     {         for($i=0; $i<count($acolumns); $i++)         {             if ($acolumns[$i] != ' '){                 $bsearchable = $this->input->get_post('bsearchable_'.$i, true);                 if(isset($bsearchable) && $bsearchable == 'true')                 {                     $this->aircraft_model->json_table_filter($acolumns, $i, $ssearch);                 }             }         }     }      $rresult = $this->aircraft_model->json_table_select($acolumns, $stable);     $ifilteredtotal = $this->aircraft_model->json_table_found($acolumns);     $itotal = $this->aircraft_model->count_all($stable);      $output = array(         'secho' => intval($secho),         'itotalrecords' => $itotal,         'itotaldisplayrecords' => $ifilteredtotal,         'aadata' => array()     );      $headers = array('3active' => false, '2cleared' => false, '4closed' => false, '1entered' => false, '5disconnected' => false);      foreach($rresult->result_array() $arow)     {         $row = array();          foreach($acolumns $col)         {             @$row[] = $arow[$col];         }          $databit = $row;         $databit['dt_rowid'] = $arow['flightid'];         $databit['dt_rowname'] = $arow['callsign'];         $output['aadata'][] = $databit;         $headers[$arow['flightsts']] = true;     }      foreach ($headers $key => $value){         if ($value == false){             $output['aadata'][] = array($key, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');         }     }      $output['aadata'][] = array('no more aircraft', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');      echo json_encode($output); } 

tableinit.js:

function inittable(){     otable = $('#main-table').datatable({         "bprocessing": true,         "bserverside": true,         "bsort": true,         "sservermethod": "get",         "sajaxsource": "ajax/json_table",         "olanguage": { "sprocessing": "<i class='icon-refresh icon-spin'></i>" },         "sdom": "<'pull-right'r><'row'<'span8'l>>ts",         "sscrolly": "400px",         "bpaginate": false,         "bscrollcollapse": true,         "aocolumndefs": [          { "bvisible": false,  "atargets": [ 1, 25 ] },         ],         "aasorting": [[ 1, "asc" ]],         "fnrowcallback": function( nrow, adata, idisplayindex, idisplayindexfull ) {             $('td:eq(0)', nrow).attr("name", "callsign");             $('td:eq(1)', nrow).attr("name", "destination");             $('td:eq(2)', nrow).attr("name", "nat");             $('td:eq(3)', nrow).attr("name", "selcal");             $('td:eq(4)', nrow).attr("name", "lvl");             $('td:eq(5)', nrow).attr("name", "mach");         },     }).rowgrouping({ igroupingcolumnindex: 0, sgroupingclass: 'nodrop', bsetgroupingclassontr: true }); } 

you'll need find data being built table, , add html there. haven't given enough information answer completely, can populate datatable in 1 of 2 methods:

1) create table in normal php output, initialize

2) use ajax source load data

both ways same problem - find table row data being created, , modify there s 1 column has button html want


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -