Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Client-side validations while updating the records via ListGrid.saveAllEdits()

    I am using ListGrid.saveAllEdits to save the records and it works fine, but even though i have a client side validation (which i have set using ListGrid.setFieldError()) saveAllEdits still executes and the request is sent to server side.
    I have tried to set showPrompt on the dsRequest but it doesn't work.
    I want a promt to be shown if there are any client side validation instead of it executing the request.
    Could you please tell me what should be done to achieve this?

    #2
    Have you get nay solution for this... I am facing similar kind of problem with ListGrid.setFieldError() when called programatically

    Comment


      #3
      During saveAllEdits(), each row is validated. If it passes validation, the row can be saved. If you are setting the error indication outside of validation, it will not prevent the attempt to save. Instead, provide custom validators on the grid fields instead.

      Comment


        #4
        I have tried with custom validators on the grid fields as well.
        Actually i am setting the error dynamically to the field in addRowEditorExitHandler handler which shows the error,but when i try to save (by using ListGrid.saveAllEdits) the error disappears before sending it to the server and hence the request is sent.

        So i assume there is something happenening in saveAllEdits which is removing the validations set dynamically either by ListGrid.setFieldError/custom validators.
        Could you please let me know how could i overcome this issue programatically?

        Comment


          #5
          If you are using SC, not SGWT, you could override saveAllEdits() and check for pending validation errors (ListGrid.hasErrors()) and return immediately if there are any. Otherwise, call the super saveAllEdits() to let the normal validation occur and the save to be triggered.

          Ultimately the conditional validators should work on a LG edit row.

          Comment


            #6
            I am using SGWT and ya we can't override saveAllEdits() here.
            The conditional validators does work on LG but only when we call saveAllEdits() the errors vanish and hence the request is sent.
            Is there any other way?

            Comment


              #7
              I'm unable to reproduce this situation. Can you provide a small, standalone example?

              Comment


                #8
                I am not able to replicate it in small standalone example with only client side data.It works fine there, but not in my case.
                Basically in addRowEditorExitHandler i send an ajax request to the server using RequestBuilder and on the response received i set the error using ListGrid.setFieldError(), but when i call ListGrid.saveAllEdits() these errors get valished.I am not able to figure out what is the issue.
                I would like to show server side validation before saving the records itself and hence followed this method.Also validation of a field in a ListGrid dependes on other fields in the ListGrid. So, sending an ajax request on addRowEditorExitHandler perfectly works for me but i am facing this issue.
                Is there any other way to achieve this?

                Comment


                  #9
                  If you want to trap errors before submitting to the server, you must use actual validators. Setting field errors manually will not stop the save attempt. You can always add your own method to attempt the save and call it instead of saveAllEdits(). It can check the grid for errors and not call saveAllEdits if there are errors.

                  Comment

                  Working...
                  X