0
したがって、テーブルに動的なテーブル行数のモダルがあります。ユーザーはテーブル行を更新できます(一部の情報を編集できます)。保存ボタンをクリックして、各行を繰り返し処理し、その新しい情報をデータベースに保存するメソッドを呼び出すことができます。モーダルのコードは以下の通りです...更新された情報を保存するために各項目を反復処理する方法はありますか?あなたが更新に来たとき、あなたがいずれかの操作を実行する必要はありません、テーブル行のそれぞれに入力されたものと一致this.state.charitiesの状態を維持する必要がメソッドを使用して子要素を反復処理するモーダルで反応する
updateCharities() {
}
render() {
return (
<Modal className="charityModal" show={this.props.show} onHide={this.props.onHide}>
<Modal.Header closeButton>
<Modal.Title>Update Your Charity Selections</Modal.Title>
</Modal.Header>
<Modal.Body>
<Table>
<thead>
<tr>
<th>Charity Name</th>
<th>Total Donations</th>
<th>Current Percentage Donation</th>
<th>Remove Charity</th>
</tr>
</thead>
<tbody>
{this.state.charities.map((charity, i) =>
// {console.log('charity', charity.percentage)}
<CharityModalEntry key={i} charity={charity} />
)}
</tbody>
</Table>
</Modal.Body>
<Modal.Footer>
<Button bsStyle="primary" onClick={this.updateCharities}>Save</Button>
<Button>Cancel</Button>
</Modal.Footer>
</Modal>
);
}