基于其他列的计算列
我有一个数据集
,其中包含在报告 (DevExpress XtraReports)
中使用的一堆列(DataSet 是数据源)。数据集有很多列,我需要读取一列(基于行类型),并决定为该行读取哪个列值,并根据行类型应用格式。
示例:
数据集
DataType IntValue RealValue StringValue DateValue
Int32 123
DateTime 1/1/2011 1:23 AM
String XYZ
...
如果数据类型是日期时间,我需要读取日期值列值等
我知道我们可以在计算列上使用数据集表达式,但无法找到一种方法来应用所需的表达式以及报表数据的格式。
是否有建议的方法在报告或数据集级别处理此问题(格式化部分除外)?
I have a Dataset
with a Bunch of Columns used in a Report (DevExpress XtraReports)
(DataSet being the DataSource). The Dataset has many columns, and i need to read a column (based on the row type), and decide which column value to read for the row, and apply formatting based on the row type.
Example:
DataSet
DataType IntValue RealValue StringValue DateValue
Int32 123
DateTime 1/1/2011 1:23 AM
String XYZ
...
If the Datatype is DateTime, i need to read the DateValue column value, etc
I know we can use DataSet Expressions on computed columns, but cant find a way to apply the required Expression, and Format Data for the Report.
Is there a suggested way to handle this in the Report or at DataSet Level (excepting the formatting part)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你为什么采取这种方法。该数据集是从 SQL 数据源还是某种后端填充的?如果是这样,为什么不直接从 SQL 获取正确格式的计算列呢?循环遍历所有记录以尝试计算“正确”列不会产生性能开销吗?
既然是报表,显示数据还不够吗?如果您确实需要使用该类型,您也可以从 sql 中引入该类型,因此您最终只会得到两列:类型和数据。如果您能详细说明您正在尝试做的事情,那将会很有帮助。
I'm not sure why you are taking this approach. This dataset is filled from a SQL datasource or some sort of backend? if that is the case, why don't you just get the computed column in the right format from the SQL directly? Wouldn't be a performance overhead to loop through all records to try and compute the "right" column?
Since it is a report, wouldn't displaying the data be enough? if you really need to use the type, you can bring that from sql as well, so you end up only with two columsn, type and data. If you can elaborate a little bit more on what you are trying to do, it will be helpful.