Textarea and select values are lost after updating datatable
Textarea and select values are lost after updating datatable
I have a on change event attached to my dataTable which seems to update the dataTable correctly but in the front end, the dropdown value is always set to the first option no matter what option is selected. What am I doing wrong? On change seems to work fine for input. For textarea as well (comments box), the value does not seem to hold.
If I remove on change function, then the front end works just fine (The dropdown option is selected correctly). However, the datatable is not updated. So I need the on change function. Here is the fiddle https://jsfiddle.net/cyzpv42o/3/
This question has an accepted answers - jump to answer
Answers
Looks like you are using
textarea
incorrectly. According to the textarea docs:You need to do something like
return "<textarea rows='4' cols='80'>" + ditem + "</textarea>" ;
instead of using the value attribute. Like this:https://jsfiddle.net/qy6t3s8w/
Kevin
Thanks @kthorngren . Looks like this solves the problem with Textarea. Any clues about select?
Your data for the select column is an empty string. I changed it to
Yes
and changed the use ofval()
to use the column data, for example:$("#eligible_1st_" + a).val(data);
.https://jsfiddle.net/vk0fdmax/1/
Not sure this is working as you expect:
The
row
parameter is the full row data. Maybe you want to row index which you can get from themeta
parameter, for examplemeta.row
. See thecolumns.render
docs for more details.Kevin