When Server-Side-Processing: How to render Column Data ?

When Server-Side-Processing: How to render Column Data ?

mdesignmdesign Posts: 72Questions: 17Answers: 0

How can i render Columns Data, when using ssp-class ?

I tried to render the column Array, like i do within my editor Examples, but this doesn't work here.

var thisDataTable = $('table').DataTable( {
    ajax:     'ssp-script.php',

// (!) doesn't work here 
columns: [
    { 
    data:  null, 
    defaultContent: ''
  },

    { 
    data: 'last_name',  
    className: '-text-left -text-bold' 
  },

    { 
    data: 'first_name',  
    className: '-text-left -text-bold' 
  },

    { 
    data: 'position',  
    className: '-text-left' 
  },
],         

Answers

  • mdesignmdesign Posts: 72Questions: 17Answers: 0
    edited July 2019

    and this is ssp-script.php

    $pdoCols = array(
      array('db' => 'id',         'dt' => 0, 'formatter' => function($d, $row) { return ''; /* leer lassen, CSS indexRow */ }),
      array('db' => 'last_name',  'dt' => 1),
      array('db' => 'first_name', 'dt' => 2),
      array('db' => 'position',   'dt' => 3),
    );
    
    
    /* ------------------------------------------------------ *
      Datatable SSP Script  
     * ------------------------------------------------------ */
    require('-incl-datatable-ssp.php'); // (!) Datatable SSP Script
    
    $pdoConn     = array(
                    'host' => 'localhost', 
                    'user' => 'root', 
                    'db'   => 'db78286_9', 
                    'pass' => '');
    $pdoTabl     = 'datatables_demo';    /* Tabelle */
    $pdoKey1     = 'id';                 /* Primary Key */
    $pdoWhereRes = 'id > 10';            /* SSP:complex string WHERE condition to apply to result set */
    $pdoWhereAll = $pdoWhereRes;         /* SSP:complex string WHERE condition to apply to the all queries */
    
    print json_encode(SSP::fct_mycomplex(
      $_GET, 
      $pdoConn,     // array PDO connection
      $pdoTabl,     // string SQL table to query
      $pdoKey1,     // string Primary key of the table
      $pdoCols,     // array Column information array
      $pdoWhereRes, // string WHERE condition to apply to result set
      $pdoWhereAll  // string WHERE condition to apply to all queries (null = alle)
    ));
    

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @mdesign ,

    but this doesn't work here.

    It should do, what's not happening? Isn't the class being applied to the cell? Would you be able to link to a page, and we can take a look.

    Cheers,

    Colin

  • mdesignmdesign Posts: 72Questions: 17Answers: 0

    i startet with your example for server_processing.php

    stops working, when i add columns[]
    http://live.datatables.net/jidosuda/1/edit

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @mdesign ,

    That's because that script is returning arrays of data, whereas you were trying to access it with objects. I've changed it so it's accessing the array here.

    Cheers,

    Colin

This discussion has been closed.