gpt4 book ai didi

react-native - 如何更改react-native-paper的DataTable中表格列的宽度

转载 作者:行者123 更新时间:2023-12-04 12:13:24 29 4
gpt4 key购买 nike

默认情况下,列是排列的,如果我尝试为单元格和标题提供宽度,结果没有变化。那么如何明确地安排列宽呢?

  <DataTable style={{ height: height }}>
<DataTable.Header>
<DataTable.Title>Name</DataTable.Title>
<DataTable.Title numeric>QTY</DataTable.Title>
<DataTable.Title numeric>AMT</DataTable.Title>
<DataTable.Title numeric>TAX</DataTable.Title>
<DataTable.Title numeric>GROSS</DataTable.Title>
</DataTable.Header>
<ScrollView>
{
data && data.length > 0 ?
data.map((item, index) => {
return (
<DataTable.Row key={index}>
<DataTable.Cell>{item.NAME}</DataTable.Cell>
<DataTable.Cell numeric>{item.QTY}</DataTable.Cell>
<DataTable.Cell numeric>{item.AMT}</DataTable.Cell>
<DataTable.Cell numeric>{item.TAX}</DataTable.Cell>
<DataTable.Cell numeric>{item.GROSS}</DataTable.Cell>
</DataTable.Row>
);
})
:
false
}
</ScrollView>
</DataTable>

最佳答案

您可以通过设置 flex 来设置特定单元格的宽度对它的值(value)。
例如:

 <DataTable.Cell style={{flex: 3}}>

关于react-native - 如何更改react-native-paper的DataTable中表格列的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64348744/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com