All chekbox becomes unchecked after the row udated on Editor edit form
All chekbox becomes unchecked after the row udated on Editor edit form
Fatou_va
Posts: 8Questions: 3Answers: 0
I have a datatables with many checkbox columns
here the columns render (7 columns in some)
if (column.fieldType === "checkbox") {
column.render = function (data, type, row) {
if (type === 'display') {
return '<input name="' + column.data + '" type="checkbox" ' + (data === true ? 'checked' : '') + ' onclick="return false" >';
}
return data;
};
column.className = "dt-body-center"
}
when I edit a row, and submit the form after a modification or not, the row is updated in the database but in datatable all chekbox becomes unchecked.
So that my datatable is updated I am forced to reload it
anybody have an idea to how to resolve this problem?
Thanks for your help!
This discussion has been closed.
Answers
Are you using
rowCallback
to update the display of the checkboxes?For example:
Kevin
Hi Kthorngren,
no, I don't use the rowCallback because in my another dataTable (who don't have the checkbox field) the row is updated after it's modification in Editor edit form without the datatable rowCallback, so I thought that that must be similar for the row with the checkbox field.
It sounds like the data being returned from the server doesn't contain
data === true
. Perhaps it contains'true'
as a string, or1
ort
?If you can post a link to the page I can take a look?
Allan
Hi Allan,
the data returned from the server is a json object and it's contain
data === 'true'
I send you a email with the link to the page. On this page I have 4 tab, my problem is in the 2nd ant the 3th tabs
Thank you. Yes, the issue is that you have a strict check for boolean true, but your server is returning strings rather than booleans.
My suggestion would be that you change
gererOngletJourVenteArticle.rest
to return boolean values for true and false rather than strings.The other option is to modify your Javascript logic check to either make it a weak check or to get for both boolean and string values.
Allan
Thank your for your answer Allan,
I have try your first suggestion but it not resolve my issue
here my Editor fields (type checkbox ) definition ( I have a function for create Editor fields)
and here my ajax function for edit submit
and in a server, my gererOngletJourVenteArticle function
and I have this function on postEdit event
but the row in datatable is not updated.
what I do wrong?
Sorry for my english!
You don't want to use a postEdit event for this - it won't help. You need to update the rowCallback where you are currently doing a strict check for
true
.Allan