Autofill not persisting to DB
Autofill not persisting to DB
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
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
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.
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 toautoFill: {editor: editor},
. This Allowed AUtoFill to fill the columns but the modal didn't appear. I changed the2.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
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.
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.
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.
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?
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
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.
correction, that was
rowId: 'id'
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
Hi Kevin,
Thats pretty much identical. Ive removed the following code (though im sure this has no bearing on it);
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.
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.
This thread might help, it sounds like the same issue,
Colin