如何解决reactjs-使用道具将数据插入表中
我正在使用reactjs。我正在使用devextreme-active-active editable-table组件。
当我想将以arrayList形式接收到的json数据与this.props.customer.customerDebts.customerAllDebts一起添加到表中时,出现错误。
我该如何解决?
<Paper style={{width: "100%"}}>
<Grid
rows={this.props.customerDebts.customerAllDebts.json}
columns={this.state.columns}
>
<EditingState
onCommitChanges={this.commitChanges}
columnExtensions={[
{columnName: "first_name",editingEnabled:false},{columnName: "last_name",]}
/>
<PagingState
defaultPageSize={5}
defaultCurrentPage={5}
/>
<IntegratedPaging />
<Table />
<TableColumnResizing
defaultColumnWidths={this.state.defaultColumnWidths}
/>
<TableHeaderRow />
<PagingPanel
pageSizes={this.state.pageSizes}
messages={this.pagingPanelMessages}
/>
<TableEditRow />
<TableEditColumn
showAddCommand
showEditCommand
showDeleteCommand
commandComponent={Command}
/>
<TableBandHeader
columnBands={this.state.columnBands}
/>
</Grid>
</Paper>
解决方法
仅当数据长度大于0时,您才需要有条件地渲染它。
<Paper style={{width: "100%"}}>
{
this.props.customerDebts.customerAllDebts.customerAllDebts.length > 0 &&
<Grid
rows={ this.props.customerDebts.customerAllDebts.customerAllDebts }
columns={this.state.columns}>
}
<EditingState
onCommitChanges={this.commitChanges}
columnExtensions={[
{columnName: "first_name",editingEnabled:false},{columnName: "last_name",]}
/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。