Why Datatable Editor sends all parameter on delete/remove action?

Why Datatable Editor sends all parameter on delete/remove action?

ionwebsionwebs Posts: 2Questions: 1Answers: 0

I have datatable editor version 1.5

When I am going to delete the record after selecting the row, it sends all the row parameters to server while i think it should send on ids to delete records.

I have no problem with issue for single record , but while I am going to delete multiple records, I got issue with request parameter/memory limit of request parameter.

Would you please let me know your suggestions?

Answers

  • allanallan Posts: 61,928Questions: 1Answers: 10,153 Site admin

    The Editor libraries don't use the values sent, other than the primary key values on delete, but sending all values was a frequently asked for feature, so we added it in.

    Are you using our libraries on the server-side or your own?

    Allan

  • ionwebsionwebs Posts: 2Questions: 1Answers: 0

    I have used your libraries on server-side (PHP).

  • allanallan Posts: 61,928Questions: 1Answers: 10,153 Site admin
    edited July 2020

    What you can do is to use preSubmit to delete the parameters that you don’t want to send - e.g.

    action                   = edit
    data[row_29][extn]       = 2947
    data[row_29][first_name] = Fiona
    data[row_29][last_name]  = Green
    data[row_29][office]     = San Francisco
    data[row_29][position]   = Chief Operating Officer (COO)
    data[row_29][salary]     = 850000
    data[row_29][start_date] = 2010-03-11
    

    could be reduced to just

    action                   = edit
    data[row_29][extn]       = 2947
    

    or even:

    action = edit
    data[row_29] = true
    

    and the delete would operate in just the same way. The key part for the delete is the index in the data property. So something like:

    editor.on(‘preSubmit’, function (e, d) {
      $.each(d.data, function (key, val) {
        d.data[key] = true;
      });
    });
    

    should do the job.

    I haven’t actually tried this locally, but I think that should be okay.

    Allan

This discussion has been closed.