Autofill not persisting to DB

Autofill not persisting to DB

rossbobrossbob Posts: 29Questions: 4Answers: 0

Hi all,

I have a sample of my code posted here;

http://live.datatables.net/nolehowe/2/edit?html,js,output

When I do an inline edit, I can see POST to my API to which persists to my DB. However, when I use Autofill (ive tested it on the column "Cost Per Unit") and while the datatable updates, there is no POST request triggered. Ive put my code on JSBin but im not entirely certain how to replicate the issue im having. I can confirm that array is not updating the values though im not certain this is conclusive. Any help you can provide is much appreciated.

Cheers,

Ross.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    Looks like you need to tell Autofill to use the Editor. See these examples:
    https://editor.datatables.net/examples/extensions/autoFill.html
    https://editor.datatables.net/examples/extensions/excel.html

    Kevin

  • rossbobrossbob Posts: 29Questions: 4Answers: 0
    edited December 2019

    ok, that looked like the issue. However, after making that change, now I am getting the following;

    TypeError: this.node is not a function
    2 dataTables.fixedColumns.min.js:48:82

    ​So I commented out the include of fixedColumns and now in spite of the change you advised, im not even getting an error now, the modal disappears and the data is left unchanged.

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    According to the Compatibility Matrix FixedColumns and Autofill have limited compatibility. The FixedColumns can't be used with AutoFill.

    I made a couple updates to your example:
    http://live.datatables.net/qasurili/1/edit

    I added idSrc to the Editor config. I changed AutoFill to autoFill: {editor: editor},. This Allowed AUtoFill to fill the columns but the modal didn't appear. I changed the 2.3.4 version of AutoFill to the Nightly version and the modal appears. Maybe @allan or @colin can let us know why the nightly version is needed for this case.

    If this doesn't help then I suggest starting with a simple page with just AutoFill to see if it works then slowly add the remaining config until you find the issue. Or please post a link to your page or another test case showing the issue.

    Kevin

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    Thanks Kevin, to clarify, I dont think i included FixedColumns on purpose. This is just the error that came up. So I removed the inclusion of the FixedColumns.js and while the js error disappeared, I still get no activity around posting data back to my DB.

    Thanks again for you responses.

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    So I have turned off pretty much everything off and cant get Autofill to work anymore. This is ever since I changed to the most recent stable. I had it previously working with AutoFill 2.3.3. Im going to change back to this version to see if it works. Ill report back soon.

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    Ok, so downgraded, AutoFill working but the handle in the wrong cell though Autofill still not updating in Datatable and also not persisting to DB. Changed back to current version 2.3.4 and removed editor attribute from autoFill def in datatable ie;

    autoFill: true,

    And not Datatable at least updating, but still not getting any persistence happening. I think im going to give AutoFill a rest at this point as I cant afford to waste any more time figuring out why it isnt working. Ill come have a look again on the next project im working on. Thanks guys.

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    Ok, so now ive noticed that rowReorder isnt working. When I remove the reference to editor, it updates in the table, just get no DB persistence. So im guessing both issues are related to my editor definition. Any ideas?

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited December 2019

    I had to add idSrc: 'id', to your example. Do you have that in your production code?

    For the example to fully work I had to use the Nightly version of AutoFill.. Was hoping @allan or @colin would have a look to see why the example needs the nightly version for the modal. You can try it from here:
    https://datatables.net/download/nightly

    RowReorder works in the example unless I comment out the line idSrc: 'id',. When you say it doesn't work are you saying you can't drag the rows or that the index isn't swapped? Please describe what happens.

    Kevin

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    Sorry, I had row: 'id' and thought thats what you meant. Ive changed over to idSrc and to the nightly autoFill includes and while the autoFill modal is different, the result is still the same.

    The RowReorder is working again now. The only thing that isnt working is that triggering of a post when I use autoFill to try and populate multiple fields with the same value.

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    correction, that was rowId: 'id'

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited December 2019

    Use rowId for Datatables and -eoption idSrc for Editor. They both need to have the correct ID column. Don't know why AutoFill doesn't post to your server. Is the example we've been working with representative of your config? It doesn't have an ajax config since we don't have a server DB we can update.

    Kevin

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    Hi Kevin,

    Thats pretty much identical. Ive removed the following code (though im sure this has no bearing on it);

            table.on( 'order.dt search.dt', function () {
                table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                    cell.innerHTML = i+1;
                } );
            } ).draw();
    

    Still does not work. All other extensions work when pushing data to the DB, just not autoFill. Im confident its something on my side but I cant think of what would cause the post event to not trigger. Im going to step through with some JS breakpoints to see whats going on.

    Cheers,

    Ross.

  • rossbobrossbob Posts: 29Questions: 4Answers: 0

    I thought I should be more clear on a point that could be important. The autofill modal comes up, except that when I click on one of the options, except for the cancel option, nothing happens. The modal just stays open but i get nothing, JS errors included.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    This thread might help, it sounds like the same issue,

    Colin

This discussion has been closed.