All Projects → Alkaids → antd-editable

Alkaids / antd-editable

Licence: other
A React component inherited from antd that can edit the table of a cell

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to antd-editable

fable-ant-design
Ant Design bindings for Fable Elmish
Stars: ✭ 23 (-20.69%)
Mutual labels:  antd
ant-table-extensions
Export, Search extensions to Ant Design's Table component.
Stars: ✭ 43 (+48.28%)
Mutual labels:  antd
isomorphic-react-with-mobx
React + MobX + React-Router + Express
Stars: ✭ 52 (+79.31%)
Mutual labels:  antd
antd-multi-cascader
A multiple cascader component for antd
Stars: ✭ 81 (+179.31%)
Mutual labels:  antd
use-antd-resizable-header
antd表格头拖拽hook
Stars: ✭ 63 (+117.24%)
Mutual labels:  antd
idpt
Internet-Delivered Psychological Therapy (IDPT) System.
Stars: ✭ 24 (-17.24%)
Mutual labels:  antd
sunrise
The rise of a new project with React, Redux-Saga and React-Router
Stars: ✭ 13 (-55.17%)
Mutual labels:  antd
blog
📝 Dev blogs.
Stars: ✭ 17 (-41.38%)
Mutual labels:  antd
next-plugin-antd-less
🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
Stars: ✭ 338 (+1065.52%)
Mutual labels:  antd
boilerplate-nextjs-antd-less
A boilerplate for Reactjs app using nextjs, redux, antd, less
Stars: ✭ 45 (+55.17%)
Mutual labels:  antd
antd-react-form-builder
Example
Stars: ✭ 74 (+155.17%)
Mutual labels:  antd
ttk-app-core
前端框架(基于react+redux)
Stars: ✭ 14 (-51.72%)
Mutual labels:  antd
wx-react-app
使用Create-React-App 和 Ant Design Pro 框架整合,演示地址:
Stars: ✭ 16 (-44.83%)
Mutual labels:  antd
react-quizzes
A React.js solution that offers a UI for creating surveys, forms and quizzes.
Stars: ✭ 25 (-13.79%)
Mutual labels:  antd
tailwind-antd-react-kit
UI Components and helpers for frontend development using Tailwind + Ant Design and React.js
Stars: ✭ 27 (-6.9%)
Mutual labels:  antd
bank-client
Frontend Application using React.js with Hooks, Redux, Saga, Ant Design, styled-components and Jest
Stars: ✭ 57 (+96.55%)
Mutual labels:  antd
laravel-react-boilerplate
Laravel React Boilerplate with Ant Design, Route-Level Code Splitting, Redux, Sanctum Auth
Stars: ✭ 49 (+68.97%)
Mutual labels:  antd
antd-pro-toolkit
🐜ant design pro toolkit.
Stars: ✭ 13 (-55.17%)
Mutual labels:  antd
public-ol-web-template
OrangeLoops Web Project Boilerplate
Stars: ✭ 28 (-3.45%)
Mutual labels:  antd
antd-etable
Editable Table base on Ant Design
Stars: ✭ 43 (+48.28%)
Mutual labels:  antd

可编辑表格(React hooks)

一个基于 antd 的 React 组件, 可以编辑表格的内容并实时保存。

NPM version NPM downloads

Features

  • 行/列可编辑
  • tab 键切换
  • 自定义表单数据校验
  • typescript 支持
  • 支持 Select 控件
  • 行/列/单元格禁用

何时使用

当表格涉及到内容的修改的时候

如何使用

安装

    $ yarn add antd-editable

使用

默认已经开启所有的单元格可编辑。如需禁用某列的可编辑,只需要在传入 columns 里设置对应列的 editable 为 false。 如需禁用某行的可编辑,只需要在传入 dataSource 里设置对应行的 editable 为 false。

每一次输入框失焦后,会在组件内部保存一个新的 dataSource ,可以传入一个 onCellChange 的回调函数用于捕获这个实时的 dataSource 用于一些类似 dispatch 的操作。

示例代码

    import Editable from 'antd-editable';
    ...

   const dataSource = [
        {
            key: "1",
            name: "金鑫",
            age: 16,
            address: "慕和兰道304",
        },
        {
            key: "2",
            name: "张海新",
            age: 17,
            address: "慕和兰道304",
            editable: false
        },
        {
            key: "3",
            name: "李鳌",
            age: 15,
            address: "慕和兰道304"
        }
    ];

    const columns = [
        {
            title: "姓名",
            dataIndex: "name",
            key: "name",
            width: "30%"
        },
        {
            title: "年龄",
            dataIndex: "age",
            key: "age",
            width: "30%"
        },
        {
            title: "住址",
            dataIndex: "address",
            key: "address",
            editable: false
        }
    ];

    function handleCellChange(nextSource){
        console.log(nextSource);
    }

    <Editable
        dataSource={dataSource}
        columns={columns}
        onCellChange={handleCellChange}
        bordered
    />

    ...

更多用法

API

antd-table 的 API 。只需在 colums 和 dataSource 里加入 editable 属性控制行列的可编辑。

参数 说明 类型 默认值
columns 列描述数据对象 object[] []
dataSource 数据数组 any[] []
onCellChange 改变dataSource的方法 function -
onSubmit 保存按钮回调,如传入此属性,则会在表格下方多出一个button function -
btnProps 保存按钮的props, 与onSubmit联用 object { style: { marginTop: 10 } }
btnText 保存按钮的文字, 与onSubmit联用 string '保存'
- antd table 的其他属性 - -
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].