Submit type 'changed' breaks local table editing

Submit type 'changed' breaks local table editing

sliekenssliekens Posts: 97Questions: 17Answers: 2
edited December 2016 in Free community support

When no ajax option is configured in Editor 1.6.0, the editor directly updates the table from the submitted form data. This behavior is broken when the form is configured to only submit changed properties.

The behavior should be changed to look up the previous value in the table and then override its existing values with the submitted form values (using $.extend). This works with all types of submit options: all, allIfChanged or changed.

https://editor.datatables.net/reference/type/form-options#submit---What-values-should-be-submitted-to-the-server

This issue is very much related to another recent discussion: https://datatables.net/forums/discussion/32838/inline-edit-server-response-for-one-field-only#latest

Replies

  • allanallan Posts: 63,834Questions: 1Answers: 10,518 Site admin

    That is what should be happening. Could you give me a link to the page showing the issue please? It would also be worth updating to 1.6.1 which fixed a bug in this area (although not directly that I don't think).

    Allan

  • sliekenssliekens Posts: 97Questions: 17Answers: 2

    I can't show a page that has the issue because our web app is an intranet site. The problem looks fixed in 1.6.1 though!

    Example given the following unmodified row:

    {
      "DT_RowId": "row_3",
      "first_name": "Ashton",
      "last_name": "Cox",
      "position": "Junior Technical Author",
      "email": "a.cox@datatables.net",
      "office": "San Francisco",
      "extn": "1562",
      "age": "66",
      "salary": "86000",
      "start_date": "2009-01-12"
    }
    

    The issue that I had was easily visible in the postSubmit event.

    editor.on('postSubmit', function(e, json, data, action) {
    });
    

    If I change the position field and submit then the data is an object that looks like this:

    {
      "action": "edit",
      "data": {
        "row_3": {
          "position": "Senior Technical Author"
        }
      }
    }
    

    In Editor 1.6.0, the returned json was not the full object.

      "data": [
        {
          "position": "Senior Technical Author"
        }
      ]
    }
    

    In Editor 1.6.1, the returned json is correct: the unmodified row is patched using the submitted data

    {
      "data": [
        {
          "DT_RowId": "row_3",
          "first_name": "Ashton",
          "last_name": "Cox",
          "position": "Senior Technical Author",
          "email": "a.cox@datatables.net",
          "office": "San Francisco",
          "extn": "1562",
          "age": "66",
          "salary": "86000",
          "start_date": "2009-01-12"
        }
      ]
    }
    

    So I don't know if you intended to fix it or if it's a lucky side effect of a different change, but I'm happy knowing that it's fixed in the newest version.

  • allanallan Posts: 63,834Questions: 1Answers: 10,518 Site admin

    Yup - that was the intended fix. The bug that I found relating to that was if idSrc was set the data wasn't being correctly read, so I rewrote that section of code to make it behave as expected.

    Good to hear that 1.6.1 does the business for you.

    Allan

This discussion has been closed.