Page not updating when using standalone editing with dot notation

Page not updating when using standalone editing with dot notation

jazjaz Posts: 16Questions: 3Answers: 0

I am having problems with the page values updating when I use dot notation. Everything works just fine when I the data-editor-field values are straight field names (i.e. name), but as soon as I add some sort of dot notation (i.e. Installations.name, I can't get the return values to update the page correctly.

Here is the relevant HTML:

<dt data-editor-label="name">Name</dt>
<dd data-editor-field="Installations.name">Test Installation</dd>

These are the POST values that are passed to my ajax call:

action: edit
data[keyless][DT_RowId]: 6
data[keyless][Installations][name]: Test Installation blah

This is what is returned from the server call:

{"data":{"Installations.name":"Test Installation blah"}}

I have also tried returning this:

{"data":{"Installations":{"name":"Test Installation blah"}}}

The values are being updated correctly in the database and when I refresh the page, it shows the updated values.

I'm sure that there is something simple that I'm missing, but I haven't been able to figure it out. Any help is appreciated!

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I think you are missing returning the 'DT_RowId`. Take a look at this example:
    https://editor.datatables.net/examples/advanced/deepObjects.html

    Go to the Ajax data tab and make an update to the table. I think it will show you how the data return should look.

    Kevin

  • jazjaz Posts: 16Questions: 3Answers: 0

    Thanks for the link to that page. Unfortunately, that didn't solve the problem. :(

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Does this document help?
    https://editor.datatables.net/manual/server

    If not then can you provide a link to the page showing the issue?

    Kevin

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

    The second return from the server that you show looks like the correct one. However, as Kevin says, if you have a link to the page showing the issue I can trace through the code to see where things are going wrong.

    Thanks,
    Allan

  • jazjaz Posts: 16Questions: 3Answers: 0

    Thanks for your help, everyone. Here is a link to the page: https://unlessweb.com/usafcc/installations/view/3

  • jazjaz Posts: 16Questions: 3Answers: 0

    My project stagnated for awhile and I'm just now picking it back up again. Did anyone have a chance to look at this?

    Thanks!

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

    Can you tell me where on that page I should click to activate the inline edit. I don't see anything obvious.

    Thanks,
    Allan

  • jazjaz Posts: 16Questions: 3Answers: 0

    Sorry, thought I had opened up the editing capabilities to be public. You should now be able to edit any of the values for Name, City, State, etc by clicking on them.

    Thanks!

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

    Awesome - thanks for that. I see the issue now. Before we go any further with the debugging though, could you possibly update your Editor to 1.6.5 - there is a decent change that this has already been resolved (I've got a feeling I remember this in the early 1.6's).

    Allan

  • jazjaz Posts: 16Questions: 3Answers: 0

    Updated. Still seems to be an issue though. :/

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

    Got it this time! Its because caused by the DT_RowId which is being included in the return. Editor is seeing that as the row identifier and thus looking for a data-editor-id attribute in the DOM. Since that isn't being found, no update happens.

    So two options:

    1. Use data-editor-id on the container element with a value that will reflect the value DT_RowId is being returned with, or
    2. Remove the DT_RowId from the JSON return object.

    Either should allow it to work correctly.

    Thanks,
    Allan

  • jazjaz Posts: 16Questions: 3Answers: 0
    edited September 2017

    Still having problems... :(

    Option #1 - I added data-editor-id to the <dl> tag. I also tried creating a div around the entire <dl> and adding data-editor-id to that. I also tried adding it to elements further up the ancestral chain. I always got the same error:
    3:132 Uncaught TypeError: Cannot set property 'DT_RowId' of undefined at Editor.<anonymous> (3:132)
    at Editor.dispatch (jquery-1.12.4.js:5226)
    at Editor.elemData.handle (jquery-1.12.4.js:4878)
    at Object.trigger (jquery-1.12.4.js:5130)
    at jQuery.fn.init.triggerHandler (jquery-1.12.4.js:5866)
    at Editor._event (dataTables.editor.js:4831)
    at Editor._submit (dataTables.editor.js:5453)
    at send (dataTables.editor.js:3648)
    at Editor.submit (dataTables.editor.js:3670)
    at HTMLDocument.<anonymous> (dataTables.editor.js:5010)

    Option #2 - I removed the DT_RowId value from the returned object. No error, but values still don't update.

  • jazjaz Posts: 16Questions: 3Answers: 0

    I've updated the url to use for testing - https://unlessweb.com/usafcc_staging/usafcc/installations/view/3

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

    I'm getting a 403 error back from the Ajax request at the moment - although the page itself appears to be loading okay.

    Thanks,
    Allan

This discussion has been closed.