Opening the editor to remove all table rows doesn't remove after confirmation

Opening the editor to remove all table rows doesn't remove after confirmation

JeeWeeJeeWee Posts: 4Questions: 1Answers: 0

Link to test case:
Sorry, it's not on a public place.

Debugger code (debug.datatables.net):

tblX

Data source: Ajax
Processing mode: Client-side
Draws: 3
Columns: 4
Rows - total: 2
Rows - after search: 2
Display start: 0
Display length: 10

Error messages shown:
none

Description of problem:

I have a table tblX with an editor editorX that runs absolutely fine. I can add select rows and press the Delete
button (having text 'Delete'), and then the selected rows are removed from the table, and the Ajax request received by the server contains the
data of the removed instances. Example trace:

Data from Ajax:

data[13][ID] =13
data[13][PropA] =6656
data[13][PropB] =1
data[11][ID] =11
data[11][PropA] =6456
data[11][PropB] =2
action =remove

Now, I want to have a button 'Delete All' that selects all rows and opens the editor with the prompt to ask if s/he is sure,
and I created this code:

function funcEmptyX() {

    var table = $('#tblX').DataTable();
    table.rows().select();
    editorX
    .remove(table.rows({ selected: true }))
    .title('Delete all: Are you sure?')
    .buttons('remove')
    .open();
}

The effect is that all rows are selected, the editor opens with the prompt as the title and a button having text 'remove',
but if I press it, no rows are removed and the Ajax request received by the server is empty (it looks like this:

Data from Ajax:

action =remove

How could I open the editor in 'remove' mode just as if it was started by pressing the table's 'Delete' button?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    What’s the response from the server to the Ajax return to delete all the rows please?

    Thanks,
    Allan

  • JeeWeeJeeWee Posts: 4Questions: 1Answers: 0

    Hi Allan, I'm using only clientside of Editor. So my own code answers (it fills "error" part of it's answer: No data received from POST request).
    The point is that if I use the Editor's standard Remove dialog, and press 'Delete', then the selected rows are clientside removed from table and the data is sent by Ajax to be removed serverside. However if the Editor is opened by my code in my post, and I press 'remove', no rows are removed from table and only an empty POST request is sent (with "action=remove" but without the data). Thanks.

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    I think I'll need to be able to see the page to be able to debug it - could you give me a link to it please?

    Thanks,
    Allan

  • JeeWeeJeeWee Posts: 4Questions: 1Answers: 0

    Hi Allan, thanks for your time.

    I use this in a non-public-accessible place, and I wouldn't know how to isolate-abstract the case to some public place. But this weekend, I will try to build this in in one of your examples, and see what happens. (Maybe I even find the answer this way, but I think not). I'll get back to you.
    regards, Jan Willem

  • JeeWeeJeeWee Posts: 4Questions: 1Answers: 0

    Hi again, I now found how to make it work, from other forum posts.

    function funcEmptyX() {
    
        var table = $('#tblX').DataTable();
        table.rows().select();
    
        editorX
        .remove(table.rows({ selected: true }).indexes())
        .title('Delete all: Are you sure?')
        .buttons('remove')
        .open();
    }
    

    so I have to add ".indexes()" to the .remove line.
    This actually does not feel too intuative to me, but anyway it works. I am under the impression ".indexes()" is the solution for quite some issues.
    Thanks, regards, Jan Willem de Pater

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Excellent, thanks for reporting back,

    Colin

This discussion has been closed.