Is there a way for Editor to omit fields that are blank/null when editing?
Is there a way for Editor to omit fields that are blank/null when editing?
My company has purchased Editor licenses and we are currently implementing it in one of our applications. I've run into a behavior when editing and submitting data, all fields are submitted as "changed" even though they haven't. This behavior occurs when the fields are blank/null.
i.e. Field A is blank, Field B is blank, and Field C is blank. If I change Field A, Editor the request will send field a,b, and c values. If I change Field A but B and C are not blank it only sends Field A in the request. I've had to write extra code on the server side to check for those null/blank fields.
Is there a way in Editor to omit those blank/null values from the request completely?
This question has accepted answers - jump to:
Answers
Are you able to give me a link to a page showing the issue so I can trace it through please?
It should be that if it is a
null
value for a field, that will be retained and not submitted to the server if there was no change in the user input value.Allan
Hi Allen,
I can't link to a page as the application requires authentication and authorization but here's some code that I hope can help. One thing I did notice was that I set defaultContent = "" if there is a null value returned from in my server response when retrieving data. If I remove that line of code I get an error "Requested unknown parameter <name of column>".
//The Editor
Yes, that is expected.
null
is the absence of data, so rather than just displaying an empty cell DataTables needs you to tell it what it should use instead. Usually that will be an empty string, but it could be<i>No data</i>
or anything else.Could you show me a sample of the two data sets that are causing the difference in behaviour (i.e. the JSON for those rows)?
Thanks,
Allan
There is another thread about a similar issue (if not identical - not sure yet!) and while answering that I though of a little more debug information that would be useful.
to your page please and let me know what the console shows when you edit a row with this issue and then submit it?
Thanks,
Allan
Hi Allan,
Your suggestion of add <i>No data</i> helped me find a solution. When I retrieve data back from my database I do a null check and set the appropriate field to "No Data". That now displays in my dataTable and when I perform an edit, it no longer sends those extra parameters.
Thanks for that!