我正在尝试编写一些脚本来简化表格排序并且已经非常接近但现在想知道我是否发现了一个错误......或者只是误解了限制。
所以我的相关代码:
var reportRunnable = reportContext.getReportRunnable();
var reportDesign = reportRunnable.getDesignInstance();
var table = reportDesign.getTable(tableName);
var sortCondition = org.eclipse.birt.report.engine.api.script.element.StructureScriptAPIFactory.createSortCondition();
sortCondition.setKey("row[\"" + columnKey + "\"]");
sortCondition.setDirection("desc");
table.removeSortConditions();
table.addSortCondition(sortCondition);
我在类列表中的第 164 行收到 NullPointerException:org.eclipse.birt.report.engine.script.internal.element.Listing,在方法 removeSortConditions ...
((org.eclipse.birt.report.model.api.simpleapi.IListing) designElementImpl).removeSortConditions();
所以上面暗示'designElementImpl'为空,进一步查看源似乎暗示要实例化'table'对象,使用了以下构造函数:
public Table( TableHandle table );
并且向上移动超类的层次结构,这意味着在 DesignElement 的构造函数中,以下内容返回 null:
designElementImpl = SimpleElementFactory.getInstance( ).getElement(handle);
有人有什么想法吗?我只是不能做我想做的事吗?
提前致谢。
编辑:可能应该添加;我正在使用 BIRT 2.5.1。