选定的数据表行,无法将选定的行存入内存

时间:2019-05-31 09:03:01

标签: javascript php jquery datatables

我对jQuery Datatable有问题。当我重新加载页面时,我希望我的表将最后选择的行存储在内存中,但是它不起作用,为什么?如何使用此功能实现代码?

var oTable = $table.DataTable({
  "scrollY": "200px",
  "scrollCollapse": true,
  "processing": true,
  "serverSide": true,
  "paging": true,
  "info": false,
  "aLengthMenu": [
    [10, 50, 75, 100, 250, 500, -1],
    [10, 50, 75, 100, 250, 500, "All"]
  ],
  "pageLength": 50,
  //"pagingType": "numbers",
  "responsive": true,
  "autoWidth": false,
  "language": {
    "sEmptyTable": "Nessun dato presente nella tabella",
    "sInfo": "",
    "sInfoEmpty": "",
    "sInfoFiltered": "(filtrati da _MAX_ elementi totali)",
    "sInfoPostFix": "",
    "sInfoThousands": ".",
    "sLengthMenu": "<div class=elem_tot>Visualizza _MENU_ allievi su  <div class=totale></div></div>",
    "sLoadingRecords": "Caricamento...",
    "sProcessing": "Elaborazione...",
    "sSearch": "Cerca:",
    "sSearch[value]": "",
    "sZeroRecords": "La ricerca non ha portato alcun risultato.",
    "oPaginate": {
      "sFirst": "Inizio",
      "sPrevious": "<img src='assets/img/Arrow_Sx.svg' class='arrow_sx' >",
      "sNext": "<img src='assets/img/Arrow_Dx.svg' class='arrow_dx'>",
      "sLast": "Fine"
    },
    "oAria": {
      "sSortAscending": ": attiva per ordinare la colonna in ordine crescente",
      "sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
    },
  },
  "ajax": {
    "url": "ajax/mediaweb/getallievi.php",
    "dataSrc": function(json_data) {
      var start = document.getElementById("start_page");
      $(start).text(json_data.start + " , " + json_data.limit);
      var allievitot = document.getElementsByClassName("totale");
      $(allievitot).text(json_data.recordsTotal);
      return json_data.rows;

    },
  },
  "fnInitComplete": function(index, row, data) {
    positionFirst();
  },
  //function(oSettings, json) {
  //$("#table_paginate").appendTo('div#table_wrapper');
  "columns": [{
    responsivePriority: 1,
    "width": "75px",
    "data": "__rank",
    className: "dt-center"
  }, {
    responsivePriority: 1,
    "width": "auto",
    "data": "Allievo",
    className: "dt-center myAnag"
  }, {
    responsivePriority: 5,
    "width": "300px",
    "data": "MediaX",
    className: "dt-center myMediaX"
  }, {
    responsivePriority: 3,
    "width": "300px",
    "data": "Media",
    className: "dt-center myMedia"
  }, {
    responsivePriority: 4,
    "width": "150px",
    "data": "Giudizio",
    className: "dt-center"
  }, {
    responsivePriority: 6,
    "width": "150px",
    "data": "Patente",
    className: "dt-center"
  }, {
    responsivePriority: 9,
    "width": "150px",
    "data": "ScadFr",
    className: "dt-center"
  }, {
    responsivePriority: 7,
    "width": "75px",
    "data": "LTesti",
    className: "dt-center"
  }, {
    responsivePriority: 8,
    "width": "75px",
    "data": "LAudio",
    className: "dt-center"
  }],
  "select": true,
  "createdRow": function(row, data, index) {
    fixPatenteAB1(row, data, index);
    fixDataEsame(row, data, index);
    setGiudizio(row, data, index);
    setFlags(row, data, index);
  },
  "rowCallback": function(row, data, index) {
    $.post("ajax/mediaweb/allieviscuola.php", {
      "id_allievo": data.Codice,
      "id_sedeClienteNeca": data.id_sedeClienteNeca
    }, function(data) {
      if (data.Presente === "0") {
        $(row).addClass("warning");
      }
    });

    $.post("ajax/mediaweb/schedeesamiallievi.php", {
      "id_allievo": data.Codice,
      "id_sedeClienteNeca": data.id_sedeClienteNeca
    }, function(data) {
      data = JSON.parse(data);
      row.cells[3].innerHTML = data.html;
      setGiudizio(row, data, 0);
    });

    $.post("ajax/mediaweb/schedequizallievi.php", {
      "id_allievo": data.Codice,
      "id_sedeClienteNeca": data.id_sedeClienteNeca
    }, function(html) {
      row.cells[2].innerHTML = html;
    });
  },
  "drawCallback": function(settings) {
    var api = new $.fn.dataTable.Api(settings);
    var pagina = Math.ceil(settings._iDisplayStart / settings._iDisplayLength) + 1;
    var paginacorrente = document.getElementById("settings");
    var pagina = $(paginacorrente).text(pagina);
    pagina = pagina[0].innerHTML;
  }
});

0 个答案:

没有答案