Announcement

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

    ListGrid.setFieldError

    I have a list grid and I will it with data from database. User cannot edit it. I would like to mark some rows with error icons. I found SmartGWT has validation feature, but I didn't find any example using it without having user input. In my case, code itself should mark errors for specific rows. I tried setFieldError, CustomValidator and some others..

    Here's my code:

    Code:
    listGridStatements = new ListGrid();
    ListGridField listGridFieldStatementsStatement = new ListGridField("Statement", "Statement");
    ListGridField listGridFieldStatementsPosition = new ListGridField("Position", "Position");
    listGridStatements.setFields(new ListGridField[] { listGridFieldStatementsStatement, listGridFieldStatementsPosition});
    addChild(listGridStatements);
    
    StatementResultRecord record1 = new StatementResultRecord("test", 1);				
    StatementResultRecord record2 = new StatementResultRecord("second one", 2);
    
    listGridStatements.setData(new StatementResultRecord[] { record1, record2 });
    
    listGridStatements.setFieldError(1, "Statement", "I would like to see this error right now, but I can't :(");

    #2
    Code:
    ListGrid lg; 
    lg.setCellFormatter(new CellFormatter() {
                            @Override
                            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                                // check for error conditions, and append error icon to return value
                                return value;
                            }
                        });
    regards,
    Andrius J.

    Comment


      #3
      Isomorphic - is the manual CellFormatter approach the best way to get errors to show up in grids where canEdit(false)? If so, is there an easy way to set the cell formatting to mimic the standard error styling for the current skin?

      Comment


        #4
        There's also enabling the editing system but having all fields be not editable.

        If you go the CellFormatter route, Canvas.imgHTML() can help you generate the image.

        Comment

        Working...
        X