Ajax updated DOM and sort order in the column not updated

Ajax updated DOM and sort order in the column not updated

dmartinezdmartinez Posts: 13Questions: 0Answers: 0
edited August 2011 in General
I am using a Ajax code for save information the side server with Java Servlet, when execute the function call back update set new values in the DOM, for totals values for example, but i maked clic in the top of clumn for rows sort, but show older sort rows.

Why datatable do not auto refresh data when i update DOM?

Thanks for the help I can provide

Best Regards

This is my Ajax implemetation with using jQuery:

$(document).ready(function() {
$("#combo<%= Evaluacion_valor.getId_valor()%>").change(function(){
$("#IndicadorValor<%= Evaluacion_valor.getId_valor()%>").html("");
$("#IndicadorValor<%= Evaluacion_valor.getId_valor()%>").prepend('');
$combovalue = document.getElementById("combo<%= Evaluacion_valor.getId_valor()%>").value;
$id_periodo_evaluacion = document.getElementById("id_periodo_evaluacion").value;
$.post("Registrar_Evaluacion", {id_person:<%=Evaluado.getId_person() %>, id_evaluacion:<%=Evaluacion.getId_evaluacion()%>,
id_evaluacion_valor:<%= Evaluacion_valor.getId_valor()%>,
id_factor_grado:$combovalue,
req_post:"guardar_factor",
id_periodo_evaluacion:$id_periodo_evaluacion,
observacion:"",
departamento:"",
cargo:"",
supervisor:""}, function(data) {
$("#IndicadorValor<%= Evaluacion_valor.getId_valor()%>").html(data.valormedicion);
$("#totalevaluacion<%=Evaluado.getId_person() %>").html(data.totalevaluacion);
});
});
});

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I think datatables only updates on certain predefined events, like clicking a column, changing page, etc.

    but you can trigger a draw at any time with the API function fnDraw(true) http://www.datatables.net/ref#fnDraw (or install a plug-in API function like fnStandingRedraw if you want the current pagination to be maintained) http://www.datatables.net/plug-ins/api#fnStandingRedraw
  • dmartinezdmartinez Posts: 13Questions: 0Answers: 0
    Hi, thanks for you comment, I am tried this:

    $(document).ready(function() {
    oTable = $('#categories').dataTable( {
    "fnDrawCallback": function() {
    alert( 'DataTables has redrawn the table' );},
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "bAutoWidth": true,
    "bStateSave": true} );
    oTable.fnDraw(true);
    } );

    But not works,

    showed a message 'DataTables has redrawn the table', but not sorted rows correctly.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    can you post a link?
  • dmartinezdmartinez Posts: 13Questions: 0Answers: 0
    I don't, because it is an intranet application, the reproduction of this problem is to update the DOM and try sort a column
This discussion has been closed.