Inline edit, presubmit .error validation issue

Inline edit, presubmit .error validation issue

keith.abramokeith.abramo Posts: 13Questions: 3Answers: 0

I'm using datatable editor with inline editing. When I make an edit on a row I use "allIfChanged" to submit my entire row and update a record on my server. Before submit I do some client side field validation using your example at . This works well when I'm only doing validation on the current field. However I want to validate all of the fields in the row to know if I should be able to submit or not and showing error message(s) at the fields which fail validation.

The issue I'm encountering is as follows.

1) I edit a cell which fires the submit event
2) editor goes into my "presubmit" event
3) I validate all my fields and one of the fields in a column im currently not editing on that row fails validation
4) I add an error to that field using .error(fieldname, mymessage)
5) I check editor.isError() and return false if any of the fields have errors
6) at this point datatables does not leave focus on the current field and keeps the input markup in that cell. the submit never happens so the row is never updated, however none of the other errors in the other cells show up so it LOOKS like to the user nothing has happened. When in reality there are errors on the other fields.

My assumtion is, when inspecting the html of another cell that should show the error, none of the datatable markup for the field errors is there so your editor code has no dom elements to inject the error text in. It looks like this markup only exists on the currently edited field.

Is there a way to make the errors show up even if the field is not in the inline edit state?


  • CT General AssemblyCT General Assembly Posts: 17Questions: 2Answers: 1

    Did you ever figure this out? I have a similar dilemma.

  • allanallan Posts: 49,594Questions: 1Answers: 7,309 Site admin

    So the issue here is that Editor assumes (not always correctly) that when you are inline editing, your other fields are all already valid, thus when they are submitted they will pass any validation.

    Since inline editing only allows one field to actually be edited by the end user, the theory goes that it is only that field which can be in error.

    Now that isn't always the case - you might have validation dependent on the changed value, or you might have invalid data and be expecting the end user to correct it. Unfortunately, at the moment Editor does not take account of other fields that might be in error. You'd need to listen for postSubmit and check the errorFields property to see if there are any errors.

    This is something that is logged and will be addressed in future - it just isn't completely clear how to do it, since the field which is in error can't be edited!


  • andyqandyq Posts: 2Questions: 0Answers: 0

    Same here, is there any solution already?

  • allanallan Posts: 49,594Questions: 1Answers: 7,309 Site admin

    Just to confirm - you are submitting a field which is in error, but which hasn't been edited? I'm afraid that is something that is still not well handled. You would need to set a global error message using error() which will be shown in the inline edit.


  • shanmugasundharamshanmugasundharam Posts: 5Questions: 2Answers: 0

    For mine also seems like same. But the different is I need to validate and throw error for the dependent fields(same row) once they were edited.

  • colincolin Posts: 4,979Questions: 0Answers: 864

    Ah, @shanmugasundharam , I just replied to your thread pointing you to here! :)

  • allanallan Posts: 49,594Questions: 1Answers: 7,309 Site admin

    For dependent fields you would need to either edit in the full form mode or with a bubble editor showing the host field and any dependents.


Sign In or Register to comment.