亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ant-design-pro?的EditableProTable表格驗證調(diào)用的實現(xiàn)代碼

 更新時間:2022年06月24日 10:29:46   作者:瀟湘羽西  
這篇文章主要介紹了ant-design-pro?的EditableProTable表格驗證調(diào)用,這里的需求是點擊外部的保存要對整個表單進行驗證,本文通過實例代碼給大家介紹的非常詳細,需要的朋友可以參考下

博客源碼https://github.com/shengbid/antdpro-demo,有需要可以下載下來看效果EditableProTable默認是在單行保存時調(diào)用表單驗證

我這里的需求是點擊外部的保存要對整個表單進行驗證

EditableProTable提供了editable屬性,可以設置form https://procomponents.ant.design/components/editable-table

代碼

import React, { useState, useEffect } from 'react'
import { Row, Col, Button, Form, message } from 'antd'
import { EditableProTable } from '@ant-design/pro-table'
const EditZTTable: React.FC = () => {
  const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([])
  const [dataSource, setDataSource] = useState<projectRiskProps[]>([])
  const [editForm] = Form.useForm()
  // 提交方法
  const onSave = async () => {
    await editForm.validateFields() // 調(diào)用表單驗證
  }
  return (
    <>
      <EditableProTable
        columns={columns}
        rowKey="id"
        value={dataSource}
        recordCreatorProps={{
          newRecordType: 'dataSource',
          record: () => ({
            id: Date.now(),
          }),
        }}
        editable={{
          type: 'multiple',
          form: editForm,
          editableKeys,
          actionRender: (row, config, defaultDoms) => {
            return [defaultDoms.delete]
          },
          onValuesChange: (record, recordList) => {
            setDataSource(recordList)
          },
          onChange: (editableKeyss, editableRows: projectRiskProps[]) => {
            setEditableRowKeys(editableKeyss)
            setDataSource(editableRows)
          },
        }}
      />
      <Row>
        <Col span={24} style={{ textAlign: 'right' }}>
          <Button style={{ margin: '15px 8px 0' }} onClick={onCancel}>取消</Button>
          <Button type="primary" onClick={onSave}>保存</Button>
        </Col>
      </Row>
    </>
  )
}

到此這篇關于ant-design-pro 的EditableProTable表格驗證調(diào)用的文章就介紹到這了,更多相關ant-design-pro表格驗證內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論