【发布时间】:2017-11-06 18:39:35
【问题描述】:
我的报告中有一个表格元素的 json 数据源。我的 json 是-
[{
"line_num": {
"oldVal": "1",
"newVal": "5"
},
"product1": {
"oldVal": "product1old",
"newVal": "product1new"
}
}, {
"line_num": {
"oldVal": "4",
"newVal": "7"
},
"product2": {
"oldVal": "product2old",
"newVal": "product2new"
}
}
]
这对我的报告有用,但是我需要从数据源添加列和表标题。
所以我尝试将它作为自己的对象添加到上面的 json 数组中,如下所示:
[{
"tableH": "My Table Header" ,
"col1H": "Line No." ,
"col2H": "My Product"
}, {
"line_num": {
"oldVal": "1",
"newVal": "5"
},
"product1": {
"oldVal": "product1old",
"newVal": "product1new"
}
}, {
"line_num": {
"oldVal": "4",
"newVal": "7"
},
"product2": {
"oldVal": "product2old",
"newVal": "product2new"
}
}
]
但问题是,当有很多行大于页面高度时,第二页上的标题为空,这是有道理的,因为从第二行开始,第一个 obj(标题 obj)是未知的,
但我不知道如何以另一种方式从服务器传递我的标头。
唯一可行的方法是将所有标题添加到数组中的每个 obj 中,但我不能这样做,因为它明显错误。
我也尝试将这些行作为一个数组,如下所示:
[{
"tableH": "My Table Header" ,
"col1H": "Line No." ,
"col2H": "My Product" ,
"Lines": [{
"line_num": {
"oldVal": "1",
"newVal": "5"
},
"product1": {
"oldVal": "product1old",
"newVal": "product1new"
}
}, {
"line_num": {
"oldVal": "4",
"newVal": "7"
},
"product2": {
"oldVal": "product2old",
"newVal": "product2new"
}
}
]
}
]
但随后字段未正确传递,例如通过 -lines.line_num.newVal ,该字段为:["5","7"]。
我真的需要这方面的帮助,如果有任何有用的回复,我将不胜感激。
【问题讨论】:
-
我们可以使用一些示例 .jrxml 文件来了解您想要的输出。你真的需要使用桌子吗?您使用的是什么版本的 JasperReports?
标签: jasper-reports