aaData returned from server not bind on DataTable [With Test Case]
aaData returned from server not bind on DataTable [With Test Case]
Giovane
Posts: 1Questions: 0Answers: 0
Hello,
I have a code (Javascript + C # + ASP.NET MVC 4) to perform an ajax call to the server and return an array with the information for the operation of the datatables. When executing the call to the server, everything happens normally and the response is generated and sent to the client. However, the datatables does not reload the new information. He remains empty with no results. There is no error in the request or response. There is no error in the formatting of the JSON response.
I researched several posts in the forum and not found a similar problem. I searched the documentation and several internet sites before posting here. I would like a little help to try to solve this problem which I can not find solution.
This link is for LIVE Execution for test case and see the problemn
http://200.98.203.38:9094/Basico/GrupoEmpresarial
Click on the Search button, one result is returned. Type Grupo in the Description field and click on Search button. Several results are returned. However, none of them are displayed in the table. There are no visible errors in the console.
-------------------------------------------------------------------
Below is the code
Table Code
[code]
Código Grupo
Descricao
[/code]
[code]
$('#tabela-pesquisa-grupo-empresarial').dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bAutoWidth": false,
"bLengthChange": false,
"bFilter": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "GrupoEmpresarial/Pesquisar",
"sServerMethod": "POST",
"aoColumns": [
{ "bSortable": false,
"bSearchable": false },
{ "mDataProp": "IDGrupoEmpresarial" },
{ "mDataProp": "Descricao" }
],
"aoColumnDefs": [
{ "sClass": "dt-column-align td-width-80", "aTargets": [2] }
],
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
oSettings.jqXHR = $.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": sSource,
"data": GetDataPesquisa(aoData, oSettings),
"success": fnCallback
});
}
});
[/code]
Below is the JSON returned
[code]
{ "aaData" : [ { "Descricao" : "Grupo Teste 02",
"IDGrupoEmpresarial" : 2
},
{ "Descricao" : "Grupo Teste 03",
"IDGrupoEmpresarial" : 3
}
],
"iTotalDisplayRecords" : 2,
"iTotalRecords" : 2,
"sEcho" : 1,
"success" : true
}
[/code]
I have a code (Javascript + C # + ASP.NET MVC 4) to perform an ajax call to the server and return an array with the information for the operation of the datatables. When executing the call to the server, everything happens normally and the response is generated and sent to the client. However, the datatables does not reload the new information. He remains empty with no results. There is no error in the request or response. There is no error in the formatting of the JSON response.
I researched several posts in the forum and not found a similar problem. I searched the documentation and several internet sites before posting here. I would like a little help to try to solve this problem which I can not find solution.
This link is for LIVE Execution for test case and see the problemn
http://200.98.203.38:9094/Basico/GrupoEmpresarial
Click on the Search button, one result is returned. Type Grupo in the Description field and click on Search button. Several results are returned. However, none of them are displayed in the table. There are no visible errors in the console.
-------------------------------------------------------------------
Below is the code
Table Code
[code]
Código Grupo
Descricao
[/code]
[code]
$('#tabela-pesquisa-grupo-empresarial').dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bAutoWidth": false,
"bLengthChange": false,
"bFilter": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "GrupoEmpresarial/Pesquisar",
"sServerMethod": "POST",
"aoColumns": [
{ "bSortable": false,
"bSearchable": false },
{ "mDataProp": "IDGrupoEmpresarial" },
{ "mDataProp": "Descricao" }
],
"aoColumnDefs": [
{ "sClass": "dt-column-align td-width-80", "aTargets": [2] }
],
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
oSettings.jqXHR = $.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": sSource,
"data": GetDataPesquisa(aoData, oSettings),
"success": fnCallback
});
}
});
[/code]
Below is the JSON returned
[code]
{ "aaData" : [ { "Descricao" : "Grupo Teste 02",
"IDGrupoEmpresarial" : 2
},
{ "Descricao" : "Grupo Teste 03",
"IDGrupoEmpresarial" : 3
}
],
"iTotalDisplayRecords" : 2,
"iTotalRecords" : 2,
"sEcho" : 1,
"success" : true
}
[/code]
This discussion has been closed.
Replies
I'm having the very same issue. Did you got the solution for it? If so, could you share it.
Thanks in advance.
Yeipis
> There is no error in the request or response.
Yes there is. The sEcho response from the server is always one in your test case. From the documentation:
> An unaltered copy of sEcho sent from the client side. This parameter will change with each draw (it is basically a draw count) - so it is important that this is implemented. Note that it strongly recommended for security reasons that you 'cast' this parameter to an integer in order to prevent Cross Site Scripting (XSS) attacks.
@yeipis: If it is not the same issue you are having, please give us a test case.
Allan