Ant design pro v4 js ProTable demo

环境 :Ant design pro v4 js

核心代码:

1、搜索框 search={true} ,如果不想显示每个字段,那么在column中设置search: false

2、表格工具栏,options={options}  有相关的几个属性,true和false

以下是我写的demo例子

import React, { useRef } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { queryModule } from './service';

const TableList = () => {
  const actionRef = useRef();
  const columns = [
    {
      title: '序号',
      dataIndex: 'index',
      search: false,
      align: 'center',
      render: (dom, record, index) => {
        if (actionRef.current.pageInfo.current > 1) {
          return (actionRef.current.pageInfo.current - 1) * actionRef.current.pageInfo.pageSize + index + 1;
        } else {
          return index + 1;
        }
      },
    },
    {
      title: '上级模块',
      dataIndex: 'parentName',
    },
    {
      title: '模块名称',
      dataIndex: 'resourceName',
    },
    {
      title: '模块key',
      dataIndex: 'resourceKey',
      search: false
    },
    {
      title: '模块描述',
      dataIndex: 'resourceDesc',
      search: false,
    },
    {
      title: '是否停用',
      dataIndex: 'isDelete',
      search: false,
      align: 'center',
      render: (dom, record, index, action) => {
        if (record.isDelete === 0) {
          return '正常';
        }
        return '停用'
      }
    }
  ];
  const options = {
    density: false,//密度
    fullScreen: false,//最大化
    reload: true, //刷新
    setting: true //设置
  }
  return (
    <PageContainer>
      <ProTable
        actionRef={actionRef}
        headerTitle="模块列表"
        rowKey="resourceId"
        request={(params, sorter, filter) => queryModule({ ...params, sorter, filter })}
        columns={columns}
        options={options}        
        search={true}//false禁用搜索
      />
    </PageContainer>
  );
};

export default TableList;

 

具体demo见官网:https://procomponents.ant.design/components/table/?current=1&pageSize=5 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值