Search in sources :

Example 1 with Field

use of com.axelor.meta.schema.views.Field in project axelor-open-suite by axelor.

the class ReportBuilderService method getHtmlTable.

/**
 * Create html table string from list of widgets(Items of grd view).
 *
 * @param fieldName Name of relational field.
 * @param widgets List of widgets in reference model's grid view.
 * @param refModel Name of reference model.
 * @return Html table created.
 */
private String getHtmlTable(String fieldName, List<AbstractWidget> widgets, String refModel) {
    String header = "";
    String row = "";
    for (AbstractWidget widget : widgets) {
        if (widget instanceof Field) {
            Field field = (Field) widget;
            String name = field.getName();
            String title = field.getTitle();
            MetaField metaField = getMetaField(name, refModel);
            if (Strings.isNullOrEmpty(title)) {
                title = getFieldTitle(name, metaField);
            }
            name = processRelational(name, metaField);
            header += "<th>" + title + "</th>";
            row += "<td>$" + fieldName + "." + name + "$</td>";
        }
    }
    String table = "<td colSpan=\"2\"><table class=\"table table-bordered table-header\">" + "<tr>" + header + "</tr>" + "<tr>" + row + "</tr>" + "</table></td>";
    return table;
}
Also used : MetaField(com.axelor.meta.db.MetaField) Field(com.axelor.meta.schema.views.Field) PanelField(com.axelor.meta.schema.views.PanelField) MetaField(com.axelor.meta.db.MetaField) AbstractWidget(com.axelor.meta.schema.views.AbstractWidget)

Aggregations

MetaField (com.axelor.meta.db.MetaField)1 AbstractWidget (com.axelor.meta.schema.views.AbstractWidget)1 Field (com.axelor.meta.schema.views.Field)1 PanelField (com.axelor.meta.schema.views.PanelField)1