Delete Row

Delete Row

blabablabablabablaba Posts: 47Questions: 19Answers: 0

Hi, I was wondering why DataTables sends entire row data on delete as opposed to just the Primary Key.

The best I could think of was that it is a security measure to check the row is identical before it is deleted?

What are your thoughts?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Originally Editor didn't, as I also couldn't see the point in it. But there are enough requests for that feature that I put it in (I think it was around v1.5). Our PHP, .NET and NodeJS libraries don't use anything other than the primary key.

    I think folks were using the row's data for validation and logging - my preference is just to read it from the db from the pkey on delete though.

    Allan

  • blabablabablabablaba Posts: 47Questions: 19Answers: 0

    Hi Allan,

    Is there a setting to send only the primary key?

    In the absence of a setting, I added the following (in case it's of use to others):

            data: function(data){
                if(data.action === 'remove'){
                    var p_ID = Object.keys(data.data)[0]
                    data.data[p_ID] = {p_ID: p_ID}
                    return data
                }
            },
    

    If there is no setting, does the above seem a reasonable approach?

    Steve

This discussion has been closed.