serverSide and select extension

serverSide and select extension

tschmittschmit Posts: 16Questions: 5Answers: 0

Datables 2.1.8
Select 2.1.0

I use serverSide and the select extension.
When I navigate between pages, the table reminds selected rows in each pages and the number of selected rows is correctly displayed.
Also rows().deselect() acts as expected. So I'm quit sure that the rowId are stored somewhere. That said I can't retreive them.
When I use table.rows( { selected: true } ).count(); it retrieves only le row selected on the displayed page.

How can I get the list of rowIds ?

This question has an accepted answers - jump to answer

Answers

  • tschmittschmit Posts: 16Questions: 5Answers: 0

    sorry, rows().deselect() only acts on the active page.

  • tschmittschmit Posts: 16Questions: 5Answers: 0

    I update to 2.2.2 and 3.0.0 and I have the same behavior

  • kthorngrenkthorngren Posts: 21,680Questions: 26Answers: 5,019

    See this example of how to get the selected row IDs across all pages.

    As a side note use rows().ids() to get the IDs. However this will only work on the current page displayed when using server side processing.

    Kevin

  • allanallan Posts: 64,016Questions: 1Answers: 10,555 Site admin
    Answer ✓

    Select 3 has a new select.cumulative() method for accessing that information (source code). Annoyingly, I don't appear to have written docs for it! I'd swear that I did - I remember doing it, but I can't see them...!

    I'll need to redo that - sorry. Server-side processing with Select can be a bit tricky, particularly when considering select all and then starting to remove items!

    Allan

  • tschmittschmit Posts: 16Questions: 5Answers: 0

    thank you both. select.cumulative() will do just fine.
    What about an unselect.cumulative() ?

  • kthorngrenkthorngren Posts: 21,680Questions: 26Answers: 5,019

    Are you asking for a way to deselect all the rows when using server side processing? If yes then see this thread. Not sure if the API plugin I created is the best way. @allan will let us know :smile:

    Kevin

  • tschmittschmit Posts: 16Questions: 5Answers: 0

    is:

    apiRegister('unselect.cumulative()', function () {
        let ctx = this.context[0];    
        if (ctx && ctx._select_set) {
            ctx._select_set.length = 0;
            var dt = new DataTable.Api(ctx);
            dt.draw();
        }
    });
    

    acceptable ?
    In my case it seems to be enough

  • tschmittschmit Posts: 16Questions: 5Answers: 0
    edited February 20

    oups, sorry, I should have read your suggestion first :)

  • allanallan Posts: 64,016Questions: 1Answers: 10,555 Site admin

    Yes, either your plugin or Kevin's select.deselectAll() looks like a decent way to do it at the moment. Frustrating that I didn't think about that behaviour as a requirement. I'll implement a suitable function in Select.

    Allan

Sign In or Register to comment.