How can i retrieve row data with Editor's delete button?

How can i retrieve row data with Editor's delete button?

JosephSongJosephSong Posts: 3Questions: 2Answers: 0
edited November 2014 in Free community support

I need to retrieve data from a row before it is deleted so i can delete from my database,
On the server side i'm using node.js.

My code:

editor = new $.fn.dataTable.Editor( {
        ajax: {
            create: {
            "url": "/license_write",
            "type": "POST"
            },
            remove: {
            "url": "/license_delete",
            "type": "DELETE"
            },
            edit: {
                "url": "/license_update",
                "type": "POST"
            }
        },
        table: '#table_id',
        fields: [{
            "label": "End User ID",
            "name": "end_user_id"
        }, {
            "label": "Sold To",
            "name": "sold_to"
        }, {
            "label": "Start Date",
            "name": "start_date"
        }, {
            "label": "Expiration Date",
            "name": "expiration_date"
        }] 
    });

my create and edit work since they send data from input fields,
How can i get the remove button to do the same with a selected row?

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    Is it a server-side action that you want to take with the data? The most secure option would be to take the ids requested for deletion in the /license_delete handler, read the data from the database and then perform whatever action is required.

    You could use preSubmit to add the data for the selected rows on the client-side, but you would then need to validate that the data submitted is actually the data that belongs to those rows (otherwise someone could monkey with it!), so I think a server-side only approach is the best way to do it.

    Regards,
    Allan

This discussion has been closed.