Inline edit always posting boolean / bit field
Inline edit always posting boolean / bit field
During an inline edit of a cell, one of the editable columns in my table (IsActive) - a boolean - always posts back along with the current cell being edited, e.g.:
"action" : "edit",
"data" : {
"69730" : {
"Unit" : "7",
"IsActive" : "false"
}
}
Is there an option or setting I can use to prevent the IsActive column from posting each time, except when it itself is being edited?
This example, https://editor.datatables.net/examples/api/checkbox.html, offers an indirect solution, but I was wondering if there were a simpler way. I am not using a checkbox.
This question has an accepted answers - jump to answer
Answers
I suspect that is happening here is that a string value is being compared to a boolean, so Editor is always finding that there is a change in value.
If you can give me a link to the page showing the issue I can check that.
Allan
I am having this issue as well. I would rather use booleans than the strings 'false' and 'true' for the data sent to the browser, but somewhere along the line, the data is being cast as a string.
I'm using Editor 1.7.0
The same happens with null values. they are cast to empty string, and the editor decides it was changed from null to empty string and sends that field along with the request.
I see that you fixed the null situation in 1.7.3:
Did that address booleans as well?
No - that was specific to
null
values that fix.Are your boolean values actually boolean when they are read from the server (i.e. they are boolean in the JSON), or are they strings there?
Do you have a link to the page you are working on so I can check it out?
Thanks,
Allan
The json returned to the client from the server on page load has the boolean value unquoted {'property':false}, not {'property':'false'}, but when any request is sent back to the server, it contains that field as a string. I'll try to get you a working example, but don't have one handy as it is an internal application.
update: I've gotten around this issue by adding the field to the editor like this:
and rendering the datatable
so now, before it calculates the difference between the original value and the new value, it converts the dropdown to the actual boolean value.
Thanks - that looks like a good workaround. I'll try to construct something locally with booleans to check it.
Allan
I upgraded to Editor 1.7.4 and Datatables 1.10.18 and this seemed to clear up the issue. Thank you!