Autofill only the text or input not all corresponding attributes
Autofill only the text or input not all corresponding attributes
rmarney
Posts: 7Questions: 2Answers: 0
I am protyping a datatable with some basic on screen summation. To do this effectively I need to maintain cell ids and my classes. When I use the autofill it appears to be overwriting the autofilled cells with the original cells id and div.
I attempted to follow this from the legacy version with no effect:
https://datatables.net/forums/discussion/29000
Any ideas?
This discussion has been closed.
Answers
Hi @rmarney ,
I'm pretty certain it's doing that already, take a look at this example. Here, I've added class/id "fred" to the first cell in the second row ("Ashton Cox"), and "stan" to the second. If you click the button, which displays the index of those classes/ids, they're the same before and after the cell is AutoFilled.
If I'm missing something, please could you let me know, with steps to reproduce, please.
Cheers,
Colin
Hi Colin,
Thanks for your help!
Please see my example
As you can see when the autofill kicks in it is taking all the values from the input (data-attr, classes, id etc..) and moving it down the line.
RM
This is correct. The built-in AutoFill fills will read the raw HTML and write back that HTML from the contents of the cell. It sounds like you want to read from the
input
value and then write back to the property of the otherinput
elements. AutoFill v2 doesn't provide that out of the box I'm afraid - a plug-in would need to be written to read the value property and write back to it.Allan
Hey Colin / Allan,
Thanks for your help before.
I have things almost working. I have the functionality working for columns, but can't figure out how to make it work across a row. Is there an equivalent to getting the cells.length for the number of selected columns?
For future readers please find this: http://live.datatables.net/nubajiya/1/
Sorry it is not pretty, trying to do a quick and dirty POC.
Thanks!
Got the horizontal working, can't believe I missed this:
http://live.datatables.net/kifufavo/6
However, identified that while the input values are changing in the datatable, the actual input values are not, so if you complete two autofill actions ie from A1->A2 then A2->B2, A2 and B2 reflect the original A2 value not the A1 value one would expect...
Excellent work!
The problem you were seeing was that you were still working with the data (i.e. the rendered HTML) rather than the DOM nodes. Use
cell.node()
to get thetd
in question and then jQuery to get the input element, from which you can read the value:http://live.datatables.net/kifufavo/9/edit
Allan
Hey Allan,
Thanks for pushing me over the finish line! I would have span my wheels for a bit for sure. JS is not a strong area for me.
I added some comments/notes to hopefully help the next person.
http://live.datatables.net/kifufavo/11/edit
If JS isn't your strong area, you must be phenomenal on your 'better' areas