Don´t show all parameters in POST

Don´t show all parameters in POST

doncidonci Posts: 11Questions: 4Answers: 0

The parameters I send in POST look like this:
draw: 1
columns[0][data]: 0
columns[0][name]:
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: 1
columns[1][name]:
columns[1][searchable]: true
columns[1][orderable]: true
columns[1][search][value]:
columns[1][search][regex]: false
columns[2][data]: 2
columns[2][name]:
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]:
columns[2][search][regex]: false
columns[3][data]: 3
columns[3][name]:
columns[3][searchable]: true
columns[3][orderable]: true
columns[3][search][value]:
columns[3][search][regex]: false
columns[4][data]: 4
columns[4][name]:
columns[4][searchable]: true
columns[4][orderable]: true
columns[4][search][value]:
columns[4][search][regex]: false
columns[5][data]: 5
columns[5][name]:
columns[5][searchable]: true
columns[5][orderable]: true
columns[5][search][value]:
columns[5][search][regex]: false
order[0][column]: 5
order[0][dir]: desc
start: 0
length: 10
search[value]:
search[regex]: false
lemmasearch:
tablename: table1

How can I disable sending the parameters like
columns[5][searchable]: true
columns[5][orderable]: true

that are true for every column?

Or empty parameters like columns[5][name]: that I never define?

Thank you in advance.

Answers

  • colincolin Posts: 15,176Questions: 1Answers: 2,589

    Hi @donci ,

    I'm not sure what the benefit of removing them would be, they would barely affect the payload and the processing time to remove them would probably be less efficient than the time to deliver the payload.

    That said, you may be able to remove them by fiddling with the data in the ajax.data function. In the example here, a new field is being added, but you may be able to remove them in that same place.

    Cheers,

    Colin

  • doncidonci Posts: 11Questions: 4Answers: 0

    Hi colin,

    Thanks for your fast reply.

    Maybe you are right about that, I thought that it would be better to define somehow in my js that columns are always searchable and orderable in order not to repeat this parameter for every single column in POST since I have many tables and many columns...

    I am familiar with the example you sent because I also add new parameters, but I don´t get what should I do to remove not all the column parameters but just some of them like

    columns[5][searchable]: true
    columns[5][orderable]: true.

    for each column.

  • colincolin Posts: 15,176Questions: 1Answers: 2,589

    Hi @donci ,

    I would suspect, for maintenance and portability, it would be better to leave them there, but no harm in prototyping or experimenting.

    With that example, data is just an object which is sent via Ajax, so you can add/remove elements from its contents, the objects and arrays, provided your back-end script can deal with it. So, yep, you could remove that fifth column stuff there if you feel it's worthwhile,

    Cheers,

    Colin

  • allanallan Posts: 61,925Questions: 1Answers: 10,153 Site admin

    The reason it is in there by default is to allow client-side switching of those features. That might or might not be what you want. You can use ajax.data and manipulate / delete the parameters you don't want as Colin suggests if you want to drop them.

    Allan

This discussion has been closed.