Serverside processing + Search textbox + Generated content for a column

Serverside processing + Search textbox + Generated content for a column

pyarzapyarza Posts: 4Questions: 3Answers: 0
edited July 2015 in Editor

Is it possible in the EDITOR to use at the same time:

  • Serverside processing
  • Search textbox
  • Generated content for a column

I have serverside configured with the POST as the type for the AJAX):

"ajax": {
    url:"./planos/php/table.hoja.php",
    type:"POST"
},
serverSide: true,

But when I try to get a filtered response from the server (by writing some text in the search textbox) I get an error as if the last field the one with the button is being requested to the server (while it is really not supposed to be sent).

This is the definition of the fields on the datatables definition (JS file):

        "columns": [
            { "data": "id_hoja"},
            { "data": "id_plano"},
            { "data": "num_hoja"},
            { "data": "usuario"},
            { "data": "nombre_fichero"},
            { "data": "fecha"},
            { "data": "ancho"},
            { "data": "alto"},
            { "data": "tamanio"},
            {
                data: null,
                name: "gestionarHoja",
                className: "center",
                defaultContent:
                    '<a href="" class="hoja_ver_hoja btn btn-info btn-sm" role="button">Ver hoja</a>'
            }   

This is the POST message being sent to the server

draw:7
columns[0][data]:id_hoja
columns[0][name]:
columns[0][searchable]:true
columns[0][orderable]:true
columns[0][search][value]:
columns[0][search][regex]:false
columns[1][data]:id_plano
columns[1][name]:
columns[1][searchable]:true
columns[1][orderable]:true
columns[1][search][value]:
columns[1][search][regex]:false
columns[2][data]:num_hoja
columns[2][name]:
columns[2][searchable]:true
columns[2][orderable]:true
columns[2][search][value]:
columns[2][search][regex]:false
columns[3][data]:usuario
columns[3][name]:
columns[3][searchable]:true
columns[3][orderable]:true
columns[3][search][value]:
columns[3][search][regex]:false
columns[4][data]:nombre_fichero
columns[4][name]:
columns[4][searchable]:true
columns[4][orderable]:true
columns[4][search][value]:
columns[4][search][regex]:false
columns[5][data]:fecha
columns[5][name]:
columns[5][searchable]:true
columns[5][orderable]:true
columns[5][search][value]:
columns[5][search][regex]:false
columns[6][data]:ancho
columns[6][name]:
columns[6][searchable]:true
columns[6][orderable]:true
columns[6][search][value]:
columns[6][search][regex]:false
columns[7][data]:alto
columns[7][name]:
columns[7][searchable]:true
columns[7][orderable]:true
columns[7][search][value]:
columns[7][search][regex]:false
columns[8][data]:tamanio
columns[8][name]:
columns[8][searchable]:true
columns[8][orderable]:true
columns[8][search][value]:
columns[8][search][regex]:false
columns[9][data]:
columns[9][name]:gestionarHoja
columns[9][searchable]:true
columns[9][orderable]:true
columns[9][search][value]:
columns[9][search][regex]:false
order[0][column]:0
order[0][dir]:asc
start:0
length:10
search[value]:mt
search[regex]:false

And this is the response from the datatables PHP script (using the datatables PHPlibrary on the server):

{"error":"Unknown field:  (index 9)","data":[]}

I understand the column [9] should not go to the server as it has the data field set as NULL.

Versions:

Editor: 1.4.2

Datatables: 1.10.0

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Yes, but you need to disable both ordering and search for the generated column (columns.orderable and columns.searchable) since of course the server-side processing can't order / search client-side generated content.

    Allan

This discussion has been closed.