This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Zellen in Tabellen formatieren

Dokumente für die Entwicklung von und mit JVx.

--Zellen in Tabellen formatieren

Postby Development@SIB » Tue Sep 29, 2009 4:07 pm



Dieser Artikel ist veraltet - Bitte verwenden Sie unser neues System

https://doc.sibvisions.com





Jede Tabelle in JVx stellt gerade und ungerade Zeilen farblich unterschiedlich dar. Das erhöht die Benutzerfreundlichkeit ungemein. In vielen Fällen ist das jedoch nicht ausreichend. Aus diesem Grund bietet die Tabelle die Möglichkeit Zellen mit unterschiedlichen Farben und Schriften darzustellen.

Die Möglichkeit zur Formatierung von Zellen wird über den CellFormatter gewährleistet.


Anwendungsbeispiel

Unsere Applikation hat eine Maske in der eine Log Tabelle aus der Datenbank angezeigt wird. Jeder Eintrag hat einen Status (ERROR, WARNING, INFO). Abhängig von diesem Status sollen alle Spalten einer Zeile eingefärbt werden.

Wir zeigen die Definition und Verwendung der Zellenformatierung:

Code: Select all
...

/** the cell format for red lines. */
public static final UICellFormat CP_RED = new UICellFormat(UIColor.red);

/** the log data. */
private RemoteDataBook rdbLog = new RemoteDataBook();

/** the log table. */
private UITable tblLog = new UITable();

...

/**
 * Initializes the UI.
 */
public void init()
{
    ...
    ...
    tblLog.setDataBook(rdbLog);
    tblLog.setCellFormatter(this, "formatLog");
}

/**
 * Formats the log table.
 *
 * @param pDataBook the log databook
 * @param pDataPage the current datapage
 * @param pDataRow the current row
 * @param pColumnName the current column name
 * @param pRow the current row
 * @param pColumn the current column
 * @return the cell format
 * @throws ModelException if an error occurs during format detection
 */
public ICellFormat formatLog(IDataBook pDataBook,
                      IDataPage pDataPage,
                      IDataRow pDataRow,
                      String pColumnName,
                      int pRow,
                      int pColumn) throws ModelException
{
    if ("ERROR".equals(pDataRow.getValue("STATE")))
    {
        return CP_RED;
    }
    else
    {
        ...
    }
   
    return null;
}


Hinweis

Wenn die Zellenformatierung eine Exception verursacht und weitergibt, dann wird diese von der Tabelle ignoriert und nicht an die Oberfläche geleitet.

Der Entwickler muss sich also selbst um die Fehlerbehandlung kümmern, wenn dies erwünscht ist!
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation (DE)