Search in sources :

Example 1 with ExpenderGridLine

use of cn.cerc.jpage.grid.lines.ExpenderGridLine in project summer-mis by cn-cerc.

the class DataGrid method outputGrid.

@Override
public void outputGrid(HtmlWriter html) {
    DataSet dataSet = this.getDataSet();
    MutiPage pages = this.getPages();
    double sumFieldWidth = 0;
    for (RowCell cell : this.getMasterLine().getOutputCells()) sumFieldWidth += cell.getFields().get(0).getWidth();
    if (sumFieldWidth < 0)
        throw new RuntimeException("总列宽不允许小于1");
    if (sumFieldWidth > MaxWidth)
        throw new RuntimeException("总列宽不允许大于600");
    html.print("<table class=\"%s\"", this.getCSSClass());
    if (this.getCSSStyle() != null)
        html.print(" style=\"%s\"", this.getCSSStyle());
    html.println(">");
    html.println("<tr>");
    for (RowCell cell : this.getMasterLine().getOutputCells()) {
        IField field = cell.getFields().get(0);
        html.print("<th");
        if (field.getWidth() == 0)
            html.print(" style=\"display:none\"");
        else {
            double val = roundTo(field.getWidth() / sumFieldWidth * 100, -2);
            html.print(" width=\"%f%%\"", val);
        }
        html.print("onclick=\"gridSort(this,'%s')\"", field.getField());
        html.print(">");
        html.print(field.getTitle());
        html.println("</th>");
    }
    html.println("</tr>");
    if (dataSet.size() > 0) {
        int i = pages.getBegin();
        while (i <= pages.getEnd()) {
            dataSet.setRecNo(i + 1);
            for (int lineNo = 0; lineNo < this.getLines().size(); lineNo++) {
                AbstractGridLine line = this.getLine(lineNo);
                if (line instanceof ExpenderGridLine)
                    line.getCell(0).setColSpan(this.getMasterLine().getFields().size());
                if (line instanceof ChildGridLine && this.beforeOutput != null)
                    beforeOutput.process(line);
                line.output(html, lineNo);
            }
            // 下一行
            i++;
        }
    }
    html.println("</table>");
    return;
}
Also used : ChildGridLine(cn.cerc.jpage.grid.lines.ChildGridLine) DataSet(cn.cerc.jdb.core.DataSet) ExpenderGridLine(cn.cerc.jpage.grid.lines.ExpenderGridLine) IField(cn.cerc.jpage.core.IField) AbstractGridLine(cn.cerc.jpage.grid.lines.AbstractGridLine)

Example 2 with ExpenderGridLine

use of cn.cerc.jpage.grid.lines.ExpenderGridLine in project summer-mis by cn-cerc.

the class DataGrid method getExpender.

@Override
public UIComponent getExpender() {
    if (expender == null) {
        expender = new ExpenderGridLine(this);
        this.getLines().add(expender);
    }
    return expender;
}
Also used : ExpenderGridLine(cn.cerc.jpage.grid.lines.ExpenderGridLine)

Aggregations

ExpenderGridLine (cn.cerc.jpage.grid.lines.ExpenderGridLine)2 DataSet (cn.cerc.jdb.core.DataSet)1 IField (cn.cerc.jpage.core.IField)1 AbstractGridLine (cn.cerc.jpage.grid.lines.AbstractGridLine)1 ChildGridLine (cn.cerc.jpage.grid.lines.ChildGridLine)1