我需要在ng2-smart-table中通过计算两列的值来创建自定义列。
我尝试使用valuePrepareFunction(),但不起作用
OrderQuantity:{
title: 'OrderQuantity',
},
UnitPrice:{
title: 'UnitPrice',
},
Total:{
title: 'Total',
type: 'custom',
//Need to get total by : OrderQuantity*UnitPrice
},我需要通过= OrderQuantity*UnitPrice获得总值
发布于 2019-09-03 11:40:40
正如您所提到的,您可以通过使用ng2-smart-table中的valuePrepareFunction来完成此操作。
根据文档,此函数将通过两个参数调用: cell,row。因此,您可以简单地使用它,如下所示。
settings = {
columns: {
OrderQuantity:{
title: 'OrderQuantity',
},
UnitPrice:{
title: 'UnitPrice',
},
Total:{
title: 'Total',
valuePrepareFunction :(cell, row) =>{
return row.OrderQuantity * row.UnitPrice;
}
}
}
}https://stackoverflow.com/questions/57727852
复制相似问题