use of cn.cerc.jpage.grid.lines.AbstractGridLine 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;
}
use of cn.cerc.jpage.grid.lines.AbstractGridLine in project summer-mis by cn-cerc.
the class StringField method format.
@Override
public String format(Object value) {
if (!(value instanceof Record))
return value.toString();
Record ds = (Record) value;
String data = getDefaultText(ds);
if (this.isReadonly()) {
if (buildUrl != null) {
HtmlWriter html = new HtmlWriter();
UrlRecord url = new UrlRecord();
buildUrl.buildUrl(ds, url);
if (!"".equals(url.getUrl())) {
html.print("<a href=\"%s\"", url.getUrl());
if (url.getTitle() != null) {
html.print(" title=\"%s\"", url.getTitle());
}
if (url.getTarget() != null) {
html.print(" target=\"%s\"", url.getTarget());
}
html.println(">%s</a>", data);
} else
html.println(data);
return html.toString();
} else
return data;
}
if (!(this.getOwner() instanceof AbstractGridLine))
return data;
return getEditor().format(ds);
}
use of cn.cerc.jpage.grid.lines.AbstractGridLine in project summer-mis by cn-cerc.
the class DoubleField method format.
@Override
public String format(Object value) {
if (!(value instanceof Record))
return value.toString();
Record ds = (Record) value;
if (this.isReadonly()) {
if (buildUrl != null) {
HtmlWriter html = new HtmlWriter();
UrlRecord url = new UrlRecord();
buildUrl.buildUrl(ds, url);
if (!"".equals(url.getUrl())) {
html.print("<a href=\"%s\"", url.getUrl());
if (url.getTitle() != null) {
html.print(" title=\"%s\"", url.getTitle());
}
if (url.getTarget() != null) {
html.print(" target=\"%s\"", url.getTarget());
}
html.println(">%s</a>", getText(ds));
} else
html.println(getText(ds));
return html.toString();
} else
return getText(ds);
}
if (!(this.getOwner() instanceof AbstractGridLine))
return getText(ds);
return getEditor().format(ds);
}
Aggregations