在进行 ARJS 报表设计的时候,常常会进行工夫类型的设置。比方短时间、长时间、短日期、长日期等等
因为工夫类型在 json 中的是以字符串的模式进行存储的,那么要在报表设计的时候要应用 Format 函数进行工夫设置的时候,就须要先把字符串转换为工夫类型,而后再进行工夫格局的设置。
上面话不多说吗,间接上手演示
1、首先进行工夫转换,把存在 Json 中的字符串类型的数据转换为工夫类型
应用“DateTime.Parse()”进行工夫类型的转换DateTime.Parse(< 格局字符串 >[, <String>])
2、关上报表设计器,进行数据源数据集的绑定
数据源:
OrderDate 代表工夫
[
{
"OrderID": 10248,
"CustomerId": "VINET",
"CompanyName": "山泰企业",
"OrderDate": "1996/01/31 10:00:00",
"Freight": 32.38,
"ProductID": 42,
"ProductName": "糙米",
"UnitPrice": 9.8,
"Quantity": 10,
"Discount": 0,
"Amount": 98,
"DiscountAmt": 0,
"NetAmount": 98
},
{
"OrderID": 10248,
"CustomerId": "VINET",
"CompanyName": "山泰企业",
"OrderDate": "1996/10/31 07:00:00",
"Freight": 32.38,
"ProductID": 72,
"ProductName": "酸奶酪",
"UnitPrice": 34.8,
"Quantity": 5,
"Discount": 0,
"Amount": 174,
"DiscountAmt": 0,
"NetAmount": 174
},
{
"OrderID": 10248,
"CustomerId": "VINET",
"CompanyName": "山泰企业",
"OrderDate": "1996/10/31 00:00:00",
"Freight": 32.38,
"ProductID": 17,
"ProductName": "猪肉",
"UnitPrice": 14,
"Quantity": 12,
"Discount": 0,
"Amount": 168,
"DiscountAmt": 0,
"NetAmount": 168
},
{
"OrderID": 10249,
"CustomerId": "TOMSP",
"CompanyName": "东帝望",
"OrderDate": "1996/07/05 00:00:00",
"Freight": 11.61,
"ProductID": 14,
"ProductName": "沙茶",
"UnitPrice": 18.6,
"Quantity": 9,
"Discount": 0,
"Amount": 167.4,
"DiscountAmt": 0,
"NetAmount": 167.4
}
]
3、数据源数据集绑定好之后,给表格绑定对应字段
4、进行工夫类型的转换
{DateTime.Parse(OrderDate, "YYYY/MM/DD HH:mm:ss")}
5、进行 Format 格局设置
6、预览后果