【发布时间】:2021-12-26 17:43:46
【问题描述】:
我想通过乘以 Quantity 和 List Price 来呈现 Value 列数据。
我找到了这样做的方法。但是当我控制台记录材料表中的 data (data 是提供给材料表数据道具的数组)时,它没有显示名为 Value 的字段。这意味着即使我们可以在材料表中看到 Value,它也不会被推送到 data 数组中。下面是控制台日志的图像。
谁能帮帮我。我希望用 Value 的值更新数据数组。
columns = {
[{
title: "Prod. ID",
field: "productid",
editComponent: props => ( <
Autocomplete options = {
selectedProductOptions
}
getOptionLabel = {
(option) => option.productid
}
inputValue = {
props.value || ''
}
onChange = {
e => props.onChange(e.target.innerText)
}
renderInput = {
(params) =>
<
MuiTextField { ...params
}
helperText = {
props.helperText
}
error = {
props.error
}
variant = "standard" /
>
}
/>
),
validate: (rowData) => (
rowData.productid === undefined ?
{
isValid: false,
helperText: 'Required *'
} :
rowData.productid === '' ?
{
isValid: false,
helperText: 'Required *'
} :
true
),
},
{
title: "Description",
field: "description",
editComponent: props => ( <
Autocomplete options = {
selectedProductOptions
}
getOptionLabel = {
(option) => option.name
}
onChange = {
e => props.onChange(e.target.innerText)
}
inputValue = {
props.value || ''
}
renderInput = {
(params) =>
<
MuiTextField { ...params
}
helperText = {
props.helperText
}
error = {
props.error
}
variant = "standard" /
>
}
/>
),
validate: (rowData) =>
rowData.description === undefined ?
{
isValid: false,
helperText: 'Required *'
} :
rowData.description === '' ?
{
isValid: false,
helperText: 'Required *'
} :
true
},
{
title: "Unit",
field: "unit",
lookup: {
Case: 'Case',
Pieces: 'Pieces'
},
width: 'min-content',
validate: (rowData) =>
rowData.unit === undefined ?
{
isValid: false,
helperText: 'Required *'
} :
rowData.unit === '' ?
{
isValid: false,
helperText: 'Required *'
} :
true
},
{
title: "Quantity",
field: "quantity",
type: 'numeric',
cellStyle: {
cellWidth: 'min-content'
},
validate: (rowData) =>
rowData.quantity === undefined ?
{
isValid: false,
helperText: 'Required *'
} :
rowData.quantity === '' ?
{
isValid: false,
helperText: 'Required *'
} :
true
},
{
title: "List Price (Rs.)",
field: "listprice",
type: 'numeric',
cellStyle: {
cellWidth: 'min-content'
},
validate: (rowData) =>
rowData.listprice === undefined ?
{
isValid: false,
helperText: 'Required *'
} :
rowData.listprice === '' ?
{
isValid: false,
helperText: 'Required *'
} :
true
},
{
title: "Value (Rs.)",
field: "value",
type: 'numeric',
cellStyle: {
width: 'min-content'
},
editable: 'never',
render: rowData => rowData.quantity * rowData.listprice,
}
]
}
【问题讨论】:
-
代码不够用?有 7 个视图,但没有答案
标签: javascript reactjs material-table