Announcement

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

    grid: save edits with validation errors

    This sounds strange, but here's the use case:

    The user is free to do any change, even when it leads to validation errors. They should be shown, but not block the user completing other fields.

    grid properties:
    saveAllEdits(true)
    (default settings regarding validate)
    uses a valuesManager, not a DataSource

    I call
    grid.startEditingNew(defaults) and the user does not fill in a required field at that time. Pressing Enter, ends edit mode, and the validator error icon comes up in the cell. That's OK.

    When the user presses a save button, I want to do grid.getRowErrors(row) for all rows to show the error messages somewhere else to the user, preventing his save action.
    But it seems that due to validation errors on the cells, the row is never saved to the grid records, and I can't see the new record in the grid.getDataAsRecordList().

    I tried grid.setValidateOnChange(false) but still, when edit mode finishes, the row is validated, errors are shown in the cells, and editValues are not saved. That's probably because of setNeverValidate(false).

    So I thought grid.setNeverValidate(true) which makes the editvalues to be saved OK, no errors are shown in the cells (bad side effect of course)
    but calling grid.validateRow(row) myself never gives me a false. So in this case, I can't get the validators to do anything.


    Any hints on what the correct settings should be?
    thanks

    #2
    Can you restate the problem? You mentioned an invalid row is never saved to the list of records, this is correct and by design. But this does not seem to block your stated use case, because there is no need for a record to be saved to the recordList to be able to get errors for it - do it by rowNum.

    Comment


      #3
      The newly added row is just a client side record (no server call to do an add), added with grid.startEditingNew.
      When there are validation errors, another field without error is marked in blue. This means there are editValues which are not 'saved' to the grid, right?

      I traverse the getDataAsRecordList,
      call a validateRow on every row,
      but it never returns as false,
      so getRowErrors also doesn't return any error.
      And that's my problem, I just can't get to the errors, even though I clearly see them :) When doing a save to the backend then, the row just goes away. I need to not trigger the save, and tell the user to fix his errors.

      Comment


        #4
        Right, so to restate, it's incorrect to traverse via getDataAsRecordList, because by design that will no contain records that have not been saved. Traverse by rowNum instead.

        Comment


          #5
          OK understood, but how do I get the number of rows then which includes the records that have not been saved?

          Comment


            #6
            listGrid.getTotalRows().

            Comment

            Working...
            X