Search in sources :

Example 1 with IColumn

use of cn.cerc.jpage.core.IColumn in project summer-mis by cn-cerc.

the class ObjectGrid method output.

@Override
public void output(HtmlWriter html) {
    html.print("<table>");
    html.print("<tr>");
    for (IColumn column : columns) {
        html.print("<th>%s</th>", column.getTitle());
    }
    html.print("<tr>");
    for (RowData row : rows) {
        html.print("<tr>");
        for (IColumn column : columns) {
            html.print("<td>");
            Object data = row.getData(column);
            html.print("%s", column.format(data));
            html.print("</td>");
        }
        html.print("<tr>");
    }
    html.print("</table>");
}
Also used : IColumn(cn.cerc.jpage.core.IColumn)

Example 2 with IColumn

use of cn.cerc.jpage.core.IColumn in project summer-mis by cn-cerc.

the class ExpenderGridLine method output.

@Override
public void output(HtmlWriter html, int lineNo) {
    DataSet dataSet = dataSource.getDataSet();
    html.print("<tr");
    html.print(" id='%s_%s'", "tr" + dataSet.getRecNo(), lineNo);
    html.print(" role=\"%s\"", dataSet.getRecNo());
    if (!this.isVisible())
        html.print(" style=\"display:none\"");
    html.println(">");
    for (RowCell item : this.getCells()) {
        IField objField = item.getFields().get(0);
        html.print("<td");
        if (item.getColSpan() > 1)
            html.print(" colspan=\"%d\"", item.getColSpan());
        if (item.getStyle() != null)
            html.print(" style=\"%s\"", item.getStyle());
        if (item.getAlign() != null)
            html.print(" align=\"%s\"", item.getAlign());
        else if (objField.getAlign() != null)
            html.print(" align=\"%s\"", objField.getAlign());
        if (item.getRole() != null)
            html.print(" role=\"%s\"", item.getRole());
        html.print(">");
        for (IField obj : item.getFields()) {
            if (obj instanceof AbstractField) {
                AbstractField field = (AbstractField) obj;
                html.print("<span>");
                if (!"".equals(field.getName())) {
                    html.print(field.getName());
                    html.print(": ");
                }
                if (field instanceof IColumn)
                    html.print(((IColumn) field).format(dataSource.getDataSet().getCurrent()));
                else if (field instanceof AbstractField)
                    outputField(html, field);
                else
                    throw new RuntimeException("暂不支持的数据类型:" + field.getClass().getName());
                html.println("</span>");
            }
        }
        html.println("</td>");
    }
    html.println("</tr>");
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) DataSet(cn.cerc.jdb.core.DataSet) IColumn(cn.cerc.jpage.core.IColumn) RowCell(cn.cerc.jpage.grid.RowCell) IField(cn.cerc.jpage.core.IField)

Example 3 with IColumn

use of cn.cerc.jpage.core.IColumn in project summer-mis by cn-cerc.

the class ColumnEditor method format.

public String format(Record ds) {
    String data = ds.getString(owner.getField());
    if (owner.getBuildText() != null) {
        HtmlWriter html = new HtmlWriter();
        owner.getBuildText().outputText(ds, html);
        data = html.toString();
    } else if (ds.getField(owner.getField()) instanceof Double) {
        DecimalFormat df = new DecimalFormat("0.####");
        data = df.format(ds.getDouble(owner.getField()));
    }
    if (!this.init) {
        dataSet = gridLine.getDataSet();
        columns = new ArrayList<>();
        for (IField field : gridLine.getFields()) {
            if (field instanceof IColumn) {
                if (((AbstractField) field).isReadonly())
                    continue;
                if (field.getWidth() == 0)
                    continue;
                columns.add(field);
            }
        }
        if (gridLine.getOwner() instanceof DataGrid) {
            DataGrid grid = (DataGrid) gridLine.getOwner();
            if (columns.size() > 0 && grid.getPrimaryKey() == null)
                throw new RuntimeException("BaseGrid.primaryKey is null");
        }
        this.init = true;
    }
    HtmlWriter html = new HtmlWriter();
    String inputStyle = "";
    html.print("<input");
    if (gridLine instanceof MasterGridLine)
        html.print(" id='%s'", this.getDataId());
    else {
        if (owner.getId() != null)
            html.print(" id='%s'", owner.getId());
        inputStyle = "width:80%;";
    }
    inputStyle += "border: 1px solid #dcdcdc;";
    html.print(" type='text'");
    html.print(" name='%s'", owner.getField());
    html.print(" value='%s'", data);
    html.print(" autocomplete='off'");
    html.print(" data-%s='[%s]'", owner.getField(), data);
    if (gridLine instanceof MasterGridLine) {
        html.print(" data-focus='[%s]'", this.getDataFocus());
        if (owner.getAlign() != null)
            inputStyle += String.format("text-align:%s;", owner.getAlign());
        if (owner.getOnclick() != null) {
            html.print(" onclick=\"%s\"", owner.getOnclick());
        } else
            html.print(" onclick='this.select()'");
    }
    if (!"".equals(inputStyle))
        html.print(" style='%s'", inputStyle);
    html.print(" onkeydown='return tableDirection(event,this)'");
    if (dataField.size() > 0) {
        for (String field : dataField) {
            html.print(" data-%s='%s'", field, ds.getString(field));
        }
    }
    if (onUpdate != null)
        html.print(" oninput=\"tableOnChanged(this,'%s')\"", onUpdate);
    else
        html.print(" oninput='tableOnChanged(this)'");
    html.println("/>");
    return html.toString();
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) MasterGridLine(cn.cerc.jpage.grid.lines.MasterGridLine) IColumn(cn.cerc.jpage.core.IColumn) HtmlWriter(cn.cerc.jpage.core.HtmlWriter) DecimalFormat(java.text.DecimalFormat) DataGrid(cn.cerc.jpage.grid.DataGrid) IField(cn.cerc.jpage.core.IField)

Example 4 with IColumn

use of cn.cerc.jpage.core.IColumn in project summer-mis by cn-cerc.

the class ChildGridLine method output.

@Override
public void output(HtmlWriter html, int lineNo) {
    html.print("<tr");
    html.print(" id='%s_%s'", "tr" + dataSource.getDataSet().getRecNo(), lineNo);
    if (!this.isVisible())
        html.print(" style=\"display:none\"");
    html.println(">");
    for (RowCell item : this.getCells()) {
        IField objField = item.getFields().get(0);
        html.print("<td");
        if (item.getColSpan() > 1)
            html.print(" colspan=\"%d\"", item.getColSpan());
        if (item.getStyle() != null)
            html.print(" style=\"%s\"", item.getStyle());
        if (item.getAlign() != null)
            html.print(" align=\"%s\"", item.getAlign());
        else if (objField.getAlign() != null)
            html.print(" align=\"%s\"", objField.getAlign());
        if (item.getRole() != null)
            html.print(" role=\"%s\"", item.getRole());
        else if (item.getFields().get(0).getField() != null)
            html.print(" role=\"%s\"", item.getFields().get(0).getField());
        html.print(">");
        for (IField obj : item.getFields()) {
            if (obj instanceof AbstractField) {
                AbstractField field = (AbstractField) obj;
                if (field instanceof IColumn)
                    html.print(((IColumn) field).format(dataSource.getDataSet().getCurrent()));
                else if (field instanceof AbstractField)
                    outputField(html, field);
                else
                    throw new RuntimeException("暂不支持的数据类型:" + field.getClass().getName());
                if (field.getTitle() != null && !"".equals(field.getTitle()))
                    html.print("<span style='float: left;'>%s:</span> ", field.getTitle());
            }
        }
        html.println("</td>");
    }
    html.println("</tr>");
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) IColumn(cn.cerc.jpage.core.IColumn) RowCell(cn.cerc.jpage.grid.RowCell) IField(cn.cerc.jpage.core.IField)

Example 5 with IColumn

use of cn.cerc.jpage.core.IColumn in project summer-mis by cn-cerc.

the class MasterGridLine method output.

@Override
public void output(HtmlWriter html, int lineNo) {
    DataSet dataSet = dataSource.getDataSet();
    html.print("<tr");
    html.print(" id='%s'", "tr" + dataSet.getRecNo());
    if (this.getPrimaryKey() != null)
        html.print(" data-rowid='%s'", dataSet.getString(this.getPrimaryKey()));
    html.println(">");
    for (RowCell cell : this.getOutputCells()) {
        IField obj = cell.getFields().get(0);
        html.print("<td");
        if (cell.getColSpan() > 1)
            html.print(" colspan=\"%d\"", cell.getColSpan());
        if (cell.getStyle() != null)
            html.print(" style=\"%s\"", cell.getStyle());
        else if (obj.getWidth() == 0)
            html.print(" style=\"%s\"", "display:none");
        if (cell.getAlign() != null)
            html.print(" align=\"%s\"", cell.getAlign());
        else if (obj.getAlign() != null)
            html.print(" align=\"%s\"", obj.getAlign());
        if (cell.getRole() != null)
            html.print(" role=\"%s\"", cell.getRole());
        else if (obj.getField() != null)
            html.print(" role=\"%s\"", obj.getField());
        html.print(">");
        if (obj instanceof AbstractField) {
            AbstractField field = (AbstractField) obj;
            if (field instanceof IColumn)
                html.print(((IColumn) field).format(dataSource.getDataSet().getCurrent()));
            else if (field instanceof AbstractField)
                outputField(html, field);
            else
                throw new RuntimeException("暂不支持的数据类型:" + field.getClass().getName());
        }
        html.println("</td>");
    }
    html.println("</tr>");
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) DataSet(cn.cerc.jdb.core.DataSet) IColumn(cn.cerc.jpage.core.IColumn) RowCell(cn.cerc.jpage.grid.RowCell) IField(cn.cerc.jpage.core.IField)

Aggregations

IColumn (cn.cerc.jpage.core.IColumn)5 IField (cn.cerc.jpage.core.IField)4 AbstractField (cn.cerc.jpage.fields.AbstractField)4 RowCell (cn.cerc.jpage.grid.RowCell)3 DataSet (cn.cerc.jdb.core.DataSet)2 HtmlWriter (cn.cerc.jpage.core.HtmlWriter)1 DataGrid (cn.cerc.jpage.grid.DataGrid)1 MasterGridLine (cn.cerc.jpage.grid.lines.MasterGridLine)1 DecimalFormat (java.text.DecimalFormat)1