使用 JS 以编程方式向 BIRT 中的表添加排序条件
我正在尝试编写一些简化表排序的脚本,并且已经非常接近,但现在想知道我是否发现了错误......或者只是误解了限制。
所以我的相关代码:
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。
I am attempting to write some script that simplifies table sorting and have been getting quite close but am now wondering if I have found a bug...or have just misunderstood limitations.
So my relevant code:
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);
I am getting a NullPointerException on line 164 in the class Listing:
org.eclipse.birt.report.engine.script.internal.element.Listing, in the method removeSortConditions...
((org.eclipse.birt.report.model.api.simpleapi.IListing) designElementImpl).removeSortConditions();
So the above implies 'designElementImpl' is null, having looked further at the source it seemed to imply that to instantiate the 'table' object, the following constructor was used:
public Table( TableHandle table );
And moving up the heirarchy of super classes, it implies that in the constructor of DesignElement, the following is returning null:
designElementImpl = SimpleElementFactory.getInstance( ).getElement(handle);
Any one any thoughts? Am I just not able to what I am trying to do?
Thanks in advance.
EDIT: Should probably add; I'm using BIRT 2.5.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我现在已经对此进行了排序...我创建了一个[更简单的]新报告,没有库依赖项,并且排序现在可以正常工作。
我也在另一个论坛上发帖,所以如果有人想要更多详细信息,请参阅 BIRT 交流论坛。
干杯。
I think I have this sorted now...I created a [simpler] new report without library dependencies and sorting is now working correctly.
I posted on another forum as well, so if anyone wants more details see BIRT Exchange Forums.
Cheers.