non-trivial grid data entry/validation

I am trying to implement some relatively complex validation/editing scenario. Datasource is client-only.

Requirements:

  1. editing should be done per cell, since value in one cell affects possible values in other cell and/or combobox values that are dynamically set via setValueMap(). For this I use setValidateByCell(true) and setEditByCell(true), which seem to work

  2. After exiting any editor, I have my validation EditorExitHandler with timer, which also seem to work:

    listGrid.addEditorExitHandler(new EditorExitHandler() {
      public void onEditorExit(EditorExitEvent event) {
        final int row = event.getRowNum();
        final int column = event.getColNum();
        Object value = event.getNewValue();
        if (listGrid.canEditCell(row, column) && value != null) {
          handleEditorExit(event.getRecord(), row, column, value);
          new Timer() {
            public void run() {
              if(listGrid.hasErrors()) {
                listGrid.startEditing(row, column, false);
              }
            }
          }.schedule(1);
        }
      }
    });

The problem is that I need to set setStopOnErrors(true) for grid to display validation result. But, after setting this attribute, grid cells with combobox editors are no longer editable by mouse (you can still use up/down keys to select a value), which is really inconvenient.

One possible workaround for me would be to use validateCell, but it is not published in SmartGWT. Any particular reason for that?

Or, I can completely discard Validator framework and do anything manually in onEditorExit, but I am trying not to reinvent the wheel.

One more problem, even if the exclamation mark is displayed in grid, the error message will not show up when you move mouse over the icon. This works for forms. Is this a bug or a feature? :slight_smile:

Any advice?

Thanks!

Hi Jimmi,

If stopOnErrors seems to be disabling ComboBoxes that would be a bug, but we’re not seeing this behavior. Can you put together a minimal, standalone test case for this?

Thanks for the reply!

I am doing my own validation now through EditorExitHandler.

It would be helpful to publish validateCell API in GWT.

Also, is there any way to set this “exclamation mark” error icon and message through API? If not, I’d love to see it published as well.

That would allow for more flexible “custom” validation in grids…

My app is fairly complex, cannot create a standalone example. However, I was trying to use the following combination of flags for a grid:

    listGrid.setCanEdit(true);
    listGrid.setModalEditing(true);
    listGrid.setEditByCell(true);
    listGrid.setValidateByCell(true);
    listGrid.setStopOnErrors(true);
    listGrid.setWaitForSave(true);

I would assume if you have a grid with combobox editor and set all these flags to it, you will be able to reproduce the problem. Maybe a combination of modalEditing and stopOnErrors does the trick (modalEditing works fine by itself).

Anton

Standalone test cases are easy to make if you think those flags are at fault. Just add them to any sample instead of simplifying your app. This clarifies whether it’s a framework problem vs, for example, something you’re doing in a custom event handler.

There are SmartClient APIs setFieldErrors(), setRowErrors() etc. They’ll be added to SmartGWT soon.