反应本机表行onClick(仅一列)

时间:2019-09-23 21:21:24

标签: javascript react-native

我创建了一个反应本机表,我想只单击“说明”列。目标是单击时在“警报”文本框中显示描述的全文。

...
import { Table, TableWrapper, Row } from 'react-native-table-component';
...
this.state = {
   tenantLedger: [],
   tableHead: ['Date of Credit', 'Description', 'Charge', 'Credit', 'Balance'],
   widthArr: [80, 95, 65, 65, 65]
};
...

const tableData = [];
for (let i = 0; i < tenantLedger.length; i += 1) {
  const rowData = [];
  rowData.push(tenantLedger[i].TRANSACTIONDATE);
  let commentSTR = '';
  if (tenantLedger[i].COMMENT.length > 12) {
    commentSTR = tenantLedger[i].COMMENT.substring(0, 13) + '...';
  } else {
    commentSTR = tenantLedger[i].COMMENT;
  }
  rowData.push(commentSTR);
  rowData.push(tenantLedger[i].CHARGE);
  rowData.push(tenantLedger[i].CREDIT);
  rowData.push(tenantLedger[i].BALANCE);
  tableData.push(rowData);
}
...

<View style={{ height: 400 }}>
    <ScrollView>
        <Table borderStyle={{ borderWidth: 1, borderColor: '#C1C0B9'}}>
            <Row
               data={this.state.tableHead}
               style={styles.head}
               textStyle={styles.text}
               widthArr={this.state.widthArr}
            />
            {
                tableData.map((rowData, index) => (
                    <Row
                       key={index}
                       data={rowData}
                       widthArr={this.state.widthArr}
                       style={[styles.row, index%2 && { backgroundColor: '#F7F6E7' }]}
                       textStyle={styles.text}
                     />
                 ))
              }
          </Table>
      </ScrollView>
  </View>

如何只为描述设置onClick并将完整描述传递给onClick函数?

谢谢

0 个答案:

没有答案