Search in sources :

Example 21 with MBrowseField

use of org.adempiere.model.MBrowseField in project adempiere by adempiere.

the class WBrowserTable method prepareTable.

/**
	 * preparate Table
	 * @param fields
	 * @param multiSelection
	 * @return
	 */
public String prepareTable(List<MBrowseField> fields, boolean multiSelection) {
    browserRows = new BrowserRow(this);
    StringBuffer sql = new StringBuffer("");
    browserFields = fields;
    clearColumns();
    int col = 0;
    //  Add columns & sql
    for (MBrowseField field : fields) {
        MViewColumn columnView = field.getAD_View_Column();
        //  create sql
        if (col > 0 && columnView.getColumnSQL().length() > 0)
            sql.append(", ");
        if (field.isKey()) {
            setKey(col);
            field.setName("#");
        }
        sql.append(columnView.getColumnSQL()).append(" ").append("AS").append(" ").append(columnView.getColumnName());
        browserRows.addBrowserField(field, col);
        if (field.isDisplayed()) {
            // Use get value get from memory entity because field can be calculated
            addColumn(field.get_ValueAsString(I_AD_Browse_Field.COLUMNNAME_Name));
        }
        //	BR [ 257 ]
        col++;
    }
    //	Set Column Class
    col = 0;
    for (MBrowseField field : fields) {
        if (field.isDisplayed()) {
            setColumnClass(col, MBrowseField.createGridFieldVO(field, browser.getWindowNo()), field.getAD_Reference_ID(), field.isReadOnly(), //	#845 Bad translation for table column
            field.get_Translation(I_AD_Browse_Field.COLUMNNAME_Name));
            col++;
        }
    }
    //	
    return sql.toString();
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) MViewColumn(org.adempiere.model.MViewColumn)

Aggregations

MBrowseField (org.adempiere.model.MBrowseField)21 MBrowse (org.adempiere.model.MBrowse)6 MViewColumn (org.adempiere.model.MViewColumn)6 GridField (org.compiere.model.GridField)6 IDColumn (org.compiere.minigrid.IDColumn)4 BigDecimal (java.math.BigDecimal)3 SQLException (java.sql.SQLException)3 I_AD_View_Column (org.adempiere.model.I_AD_View_Column)2 PackOut (org.adempiere.pipo.PackOut)2 MColumn (org.compiere.model.MColumn)2 MQuery (org.compiere.model.MQuery)2 MTable (org.compiere.model.MTable)2 Query (org.compiere.model.Query)2 AttributesImpl (org.xml.sax.helpers.AttributesImpl)2 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1