draw()

draw()

devadriandroiddevadriandroid Posts: 1Questions: 1Answers: 0
edited December 2017 in Free community support

Que tal, espero explicarme correctamente:

Tengo una tabla donde renderizo en la primera columna elementos checkbox, el problema es que al seleccionar algunos, por ejemplo de la primera pagina, al pasar a la siguiente pagina, estos se deseleccionan.
Mi paginacion va de 10 en 10 y utilizo pipeline para cargar de 20 registros en cache,
yo encuentro que el problema es que al cambiar, reordenar, la tabla es completamente redibujada (draw), y por eso no se mantiene mi seleccion.

Espero puedan ayudarme!
Agradezco de antemano su atención.

Dejo un breve fragmento de como obtengo mis columnas, mi forma dinamica por tabla
[code]
var getComlumns = function(str){
switch(str){
case 'columns_group_participants':
return [
{
orderable: false,
className: "custom-width",
data: "serviceid",
render: function ( data, type, row ) {
return "

'"+ "

";
},
"targets": 0
},
...
...
[code]

Answers

  • rf1234rf1234 Posts: 2,984Questions: 87Answers: 421
    edited December 2017

    Well, if you go to page 2 the selected element is removed from the DOM so you have no information what you selected before. You would need to save the ids of the selected rows in your script and monitor deselection as well. In case the user moves back to page one you would need to programmatically select the respective rows based on the saved ids.

    Or you get rid of pagination and do scrolling.

    You could save the id of the selected records like this:

    var selectedId = '#' + yourTable.row({selected: true}).id();
    

    Then when scrolling back do this:

    yourTable.row(selectedId).select();
    
    

    When the user deselects you would need to delete the saved id.

    All of this of course would need to be done with the right events and in arrays.

This discussion has been closed.