server-side put hidden field

server-side put hidden field

theteotheteo Posts: 15Questions: 3Answers: 0

Javascript (resume)

"columns": [

        { "data": "cpf" },
        { "data": "nome" , },
        { "data": "sobrenome" , },
        { "data": "celular" },
        { "data": "email" },
        {                
        "data": null,
        "defaultContent": "<form method=\"post\" action=\"\"><input type=\"hidden\" id=\"idcontrib\" name=\"idcontrib\" value=\"  => "DATA": "ID" <=    \"><button type=\"submit\" class=\"btn btn-warning btn-xs\" name=\"edit_contrib\">Editar</button>&nbsp;&nbsp;<button type=\"submit\" class=\"btn btn-danger btn-xs\" name=\"exc_contrib\">Excluir</button></form>"
    },

Server-side script

 $columns = array(

array( 'db' => 'cpf', 'dt' => 'cpf' ),
array( 'db' => 'fnome',  'dt' => 'nome' ),
array( 'db' => 'lnome',  'dt' => 'sobrenome' ), 
array( 'db' => 'celular1',  'dt' => 'celular' ),
array( 'db' => 'email',  'dt' => 'email' ),
array( 'db' => 'id_contrib', 'dt' => 'id' )

);

How can i put inside hidden field the value ' "data": "id" ' ?

Answers

  • theteotheteo Posts: 15Questions: 3Answers: 0

    somebody can help me here:

    "columns": [
    
        { "data": "cpf" },
        { "data": "nome" , },
    { "data": "sobrenome" , },
        { "data": "celular" },
        { "data": "email" },
    {                
    "data": null,
    
       "defaultContent": "<form method=\"post\" action=\"\"><input type=\"hidden\" id=\"idcontrib\" name=\"idcontrib\" value=\"<id>\"><button type=\"submit\" class=\"btn btn-warning btn-xs\" name=\"edit_contrib\">Editar</button>&nbsp;&nbsp;<button type=\"submit\" class=\"btn btn-danger btn-xs\" name=\"exc_contrib\">Excluir</button></form>"
       },
    

    How can i do that ? Please.

  • theteotheteo Posts: 15Questions: 3Answers: 0

    so guys, somebody ? Maybe you Allan.

  • theteotheteo Posts: 15Questions: 3Answers: 0
    edited November 2014

    Resolved

    script

    $(document).ready(function() {
    
    var otable = $('#datatable_fixed_column').DataTable({
    
    "processing": true,
    "serverSide": true,
    "ajax": "server_processing/contribuintes.php",
    
    "order": [[ 2, "asc" ]],
    
    "columnDefs": [
    
        { "width": "5%", "targets": 0 },
        { "width": "10%", "targets": 1 },
        { "width": "15%", "targets": 2 },
        { "width": "20%", "targets": 3 },
        { "width": "10%", "targets": 4 },
        { "width": "20%", "targets": 5 },
        { "width": "5%", "targets": 6 },
        { "render": actionlinks,
          "data": null,         
          "targets": [7], "width": "15%", "targets": 7 },
    
    ],
    
    });
    
    function actionlinks(data, type, full) {
    
        return '<form method="post" action=""><input type="hidden" id="idcontrib" name="idcontrib" value="' + full[0] + '"><button type="submit" class="btn btn-warning btn-xs" name="edit_contrib">Editar</button>&nbsp;&nbsp;<button type="submit" class="btn btn-danger btn-xs" name="exc_contrib">Excluir</button>&nbsp;&nbsp;<button type="submit" class="btn btn-info btn-xs" name="ativa_contrib">Reativar</button></form> ';
    
    }
    

    Server-side

    $table = 'tbl_contribuintes';
    $primaryKey = 'id_contrib';
    
    $columns = array(
    
    array( 'db' => 'id_contrib', 'dt' => 0 ),
    array( 'db' => 'cpf', 'dt' => 1 ),
    array( 'db' => 'fnome',  'dt' => 2 ),
    array( 'db' => 'lnome',  'dt' => 3 ),   
    array( 'db' => 'celular1',  'dt' => 4 ),
    array( 'db' => 'email',  'dt' => 5 ),
    array( 'db' => 'id_status',  'dt' => 6 ),
    
    );
    
    $sql_details = array(
    'user' => 'root',
    'pass' => 'XXX',
    'db'   => 'XXX',
    'host' => 'localhost'
    );
    
    require( 'ssp.class.php' );
    
    echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
    );
    

    tks Anderson Torres
    http://andersontorres.com.br/

This discussion has been closed.