return value on button Datatable Server-Side

return value on button Datatable Server-Side

theteotheteo Posts: 15Questions: 3Answers: 0
edited November 2014 in Free community support

So guys, how can i put a button in my column this form:
ProtOcolo Assunto Action
001 lalalalala print

Im using datatable server-side:

<table id="datatable_fixed_column" class="table table-striped table-bordered" width="100%">
<thead>
 <tr>
        <th>Protocolo</th>
        <th>Assunto</th>
        <th>Action</th>
</tr>
</thead>
</table>

<script type="text/javascript">

$(document).ready(function() {

    var otable = $('#datatable_fixed_column').DataTable({

     "processing": true,
     "serverSide": true,
     "ajax": "server_processing/protocolos.php",
     "order": [[ 0, "asc" ]],

         "columnDefs": [
        { "width": "10%", "targets": 0 },
        { "width": "70%", "targets": 1 },
        { "width": "20%", "targets": 2 }
         ],

        columns: [
        { data: "protocolo" },
        { data: "assunto" },           
        {
        data: null,
        defaultContent: '<form method="post" action=""><input type="hidden" id="idcontrib" name="idcontrib" value="id_protocolo"><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>'
        }           
    ],

    "sDom": "<'dt-toolbar'<'col-xs-6'f><'col-xs-6'<'toolbar'>>r>"+
            "t"+
            "<'dt-toolbar-footer'<'col-xs-6'i><'col-xs-6'p>>"
    });

     $("div.toolbar").html('<div class="text-right"><img src="img/logo2.png" alt="SmartAdmin" style="width: 111px; margin-top: 3px; margin-right: 10px;"></div>');

})

</script>

protocolos.php

<?php 
$table = 'tbl_protocolos_teste';
$primaryKey = 'id_protocolo';

$columns = array(
array( 'db' => 'protocolo', 'dt' => 0 ), 
array( 'db' => 'assunto',  'dt' => 1 ),
array( 'db' => 'id_protocolo',  'dt' => 2 )
);

$sql_details = array(
'user' => 'root',
'pass' => '$#$#$#',
'db'   => 'bbbb',
'host' => 'localhost'
);

require( 'ssp.class.php' );

echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

my problem,
first
the value protocolo and assunto They are not being loaded

{ data: "protocolo" },
{ data: "assunto" },  

Second
How do I load the id_protocolo value in hidden field ?

<input type="hidden" id="idcontrib" name="idcontrib" value="id_protocolo">  

but if I delete these lines data are listed:

columns: [
        { data: "protocolo" },
        { data: "assunto" },           
        {
        data: null,
        defaultContent: '<form method="post" action=""><input type="hidden" id="idcontrib" name="idcontrib" value="id_protocolo"><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>'
        }           
    ],
This discussion has been closed.