API de pesquisa de coluna com server side processing.
API de pesquisa de coluna com server side processing.
DumbleDW
Posts: 15Questions: 2Answers: 0
in DataTables
Alguém poderia me mostrar um exemplo do uso da API de pesquisa de coluna junto com processamento do lado do servidor?
This question has accepted answers - jump to:
Answers
The Server Side Processing docs explain the protocol used. In the docs it shows the column search information is passed as part of the parameters. Your server script is responsible looking at the parameters to setup the DB query for each column search.
The ssp.class.php file used in the Server Side examples can be found here. This will give you the basics of what needs to be in your server script.
Kevin
Me tira uma duvida, tem que ser alterado alguma coisa no ssp.class? porque simplesmente não funciona em meu código, ele fica como processing... infinito.
Check the browser's console for errors.
Kevin
Não relata nenhum erro, ao olhar o console na parte de rede ele ainda mostra os resultados
.
The problem is your server script is returning
draw: 0
. The server side docs provide the details of this parameter. It is a sequence number that the client uses to make sure its processing the correct response. When Datatables initializes it sendsdraw: 1
, look at the request tab, and expectsdraw: 1
in the response. The response should never have 0.Kevin
Ao mudar o tipo _GET para _POST o draw foi alterado para 1 porém a tabela me retornou vazia:
Segue os links dos códigos:
https://sourceb.in/5JhOm30qpm
https://sourceb.in/6zKSDDkt9U
Please post your Datatables initialization code.
Kevin
Postado:
https://sourceb.in/5JhOm30qpm
https://sourceb.in/6zKSDDkt9U
You have this:
Your row data are in arrays but you have defined
columns.data
which is telling Datatables that your row data is objects. Since the objects aren't there its using thedefaultContent
setting to display empty data. See the data docs for more details.Its better to use objects. My suggestion is to change your server script to return object structured rows. See this example.
Kevin
Muito obrigado Kevin, retornando estruturas de objeto funcionou perfeitamente, sabe me dizer se tem como adaptar com essa função?
https://datatables.net/examples/api/multi_filter_select.html
See if this thread helps.
Kevin