当前位置: 首页 > news >正文

泗阳做网站公司seo快速排名百度首页

泗阳做网站公司,seo快速排名百度首页,编写网页所用的语言是,汕尾手机网站开发React Antd ProTable 如何设置类似于Excel的筛选框 目标:在web页面的table表格中完成类似于EXCEL的Filter筛选功能。 示例图:点击标题列上方的漏斗状图标,即可对数据进行筛选。 ProTable 前景提要 ProTable API中有说明,是有…

React Antd ProTable 如何设置类似于Excel的筛选框

目标:在web页面的table表格中完成类似于EXCEL的Filter筛选功能。

示例图:点击标题列上方的漏斗状图标,即可对数据进行筛选。
页面实现

ProTable 前景提要

ProTable API中有说明,是有filter筛选功能的

参数说明类型默认值版本
filters表头的筛选菜单项object[]--
onFilter本地模式下,确定筛选的运行函数function--

个人理解:
filters 设置被筛选的数据,数据形式是object
onFilter 设置筛选的函数方法就是自定义一个函数方法用于筛选

理论阶段

根据 前景提要可知,设置筛选需要两个设置。

1.数据准备

  • 既然要筛选,那必须是所有数据在里面,且是去除重复后的数据。这样子才算筛选。
    那重点就是数据去重存储

  • 可以看到我是有多列需要筛选,那还是抽象封装一个方法数据去重,和存储的方法来调用方便低调用和维护。

2.筛选函数

  • 就是你选择了筛选框的数据,你要自定义匹配方式,成功就是true,失败就是false。
    页面就会显示匹配成功的数据。

  • 也是封装方法都用这个匹配方法即可

实践阶段

1.数据准备

  1. 首先在ProTable中使用request获取数据,调用生成数据方法
 request={async (params, sorter, filter) => {const r = await queryData(current_table, { ...params, sorter, filter });//获取的数据为r,若有数据则,生成筛选数据。if (r?.data) {generateFilterOptions(r.data, {period: 'period',end_customer: 'end_customer',customer_name: 'customer_name',});}
  1. 编写生成数据方法generateFilterOptions
/**
3. data 原数据 propertyMappings 筛选模板*/function generateFilterOptions(data: any[],propertyMappings: { [key: string]: string },handleNullForKeys?: string[],): void {const groupedOptions: { [key: string]: Option[] } = {};// 遍历数据,直接构建分组选项data.forEach((item) => {Object.entries(propertyMappings).forEach(([targetKey, sourceKey]) => {let value = item[sourceKey];if (handleNullForKeys?.includes(targetKey) && value === null) value = '';if (!groupedOptions[targetKey]) {groupedOptions[targetKey] = [];}// 确保每个值只添加一次,利用 Set 去重const valueSet = new Set(groupedOptions[targetKey].map((option) => option.value));if (!valueSet.has(value)) {groupedOptions[targetKey].push({ key: targetKey, text: String(value), value });}});});// 将生成的选项设置到状态中setFilterOptions(groupedOptions);}
  1. 用useState存储数据
const [filterOptions, setFilterOptions] = useState<{ [key: string]: Option[] }>({});
  1. 可以看一下groupedOptions的数据格式,最后需要的就是
    {text:‘2023-01’,value:‘2023-01’} 前面的key是用于不同列分组的
    在这里插入图片描述

2.准备筛选函数

// 通用的过滤函数const genericOnFilter = (dataIndex: string) => (value: any, record: any) => {if (value !== null) {if (value === '') {return record[dataIndex] === '';}if (record[dataIndex] !== null && (typeof value === 'string' || typeof value === 'number')) {return String(record[dataIndex]).indexOf(String(value)) === 0;}} else {return record[dataIndex] === null;}return false;};

因为null可能或出错,还有空字符串不能使用indexof所以写出这样。
value 是筛选选中的数据,record[dataIndex]是列的数据.
匹配上需要显示的数据就返回true,不需要的就返回false

3.开始使用

上面所说的API都是ProTable 的column API

  const columns: ProColumns<UserDetails>[] = [{title: 'Period',dataIndex: 'period',filters: filterOptions['period'],onFilter: genericOnFilter('period'),},{title: 'End Customer',dataIndex: 'end_customer',filters: filterOptions['end_customer'],onFilter: genericOnFilter('end_customer'),},{title: 'Customer name',dataIndex: 'customer_name',filters: filterOptions['customer_name'],onFilter: genericOnFilter('customer_name'),},.....

结束

理论上应该讲完了,可能还有更方便快捷的方法。
有疑问或想法可以评论区留言。


文章转载自:
http://knobstick.stph.cn
http://honiara.stph.cn
http://laky.stph.cn
http://conamore.stph.cn
http://horticulture.stph.cn
http://disorient.stph.cn
http://sulfurate.stph.cn
http://stateside.stph.cn
http://pleomorphous.stph.cn
http://bypass.stph.cn
http://oar.stph.cn
http://napier.stph.cn
http://hoary.stph.cn
http://assessor.stph.cn
http://revises.stph.cn
http://marquis.stph.cn
http://redeploy.stph.cn
http://haemostat.stph.cn
http://inelastic.stph.cn
http://ossifrage.stph.cn
http://airscrew.stph.cn
http://chronically.stph.cn
http://opponent.stph.cn
http://deexcitation.stph.cn
http://lovage.stph.cn
http://selangor.stph.cn
http://married.stph.cn
http://arrogantly.stph.cn
http://bandsaw.stph.cn
http://effervesce.stph.cn
http://bonism.stph.cn
http://lacunaris.stph.cn
http://naturopathy.stph.cn
http://unindexed.stph.cn
http://heading.stph.cn
http://jeep.stph.cn
http://vandalise.stph.cn
http://bedaze.stph.cn
http://lacedaemon.stph.cn
http://iodometry.stph.cn
http://palatogram.stph.cn
http://microbial.stph.cn
http://gene.stph.cn
http://rostrum.stph.cn
http://stanza.stph.cn
http://microcapsule.stph.cn
http://stalagmitic.stph.cn
http://unheated.stph.cn
http://expressively.stph.cn
http://taxicab.stph.cn
http://zymosterol.stph.cn
http://maestoso.stph.cn
http://porkbutcher.stph.cn
http://unmoved.stph.cn
http://transposition.stph.cn
http://fouquet.stph.cn
http://synarchy.stph.cn
http://zoril.stph.cn
http://menominee.stph.cn
http://tragopan.stph.cn
http://convalescence.stph.cn
http://burst.stph.cn
http://periodic.stph.cn
http://rachilla.stph.cn
http://cem.stph.cn
http://labyrinthic.stph.cn
http://dim.stph.cn
http://jellaba.stph.cn
http://noseless.stph.cn
http://travelling.stph.cn
http://protectionism.stph.cn
http://spitter.stph.cn
http://crossbreed.stph.cn
http://director.stph.cn
http://xinjiang.stph.cn
http://glutaminase.stph.cn
http://wrest.stph.cn
http://jyland.stph.cn
http://ceria.stph.cn
http://petrosal.stph.cn
http://lethe.stph.cn
http://fanaticize.stph.cn
http://riverway.stph.cn
http://pursue.stph.cn
http://fix.stph.cn
http://giftie.stph.cn
http://yetorofu.stph.cn
http://diachylon.stph.cn
http://genesis.stph.cn
http://papreg.stph.cn
http://branchiae.stph.cn
http://wdp.stph.cn
http://sequestrene.stph.cn
http://oddfish.stph.cn
http://faller.stph.cn
http://defy.stph.cn
http://myrrh.stph.cn
http://oso.stph.cn
http://woodpie.stph.cn
http://spermatocide.stph.cn
http://www.15wanjia.com/news/93728.html

相关文章:

  • 布吉附近做网站seo推广是什么意思呢
  • wordpress手机不显示图片厦门seo培训学校
  • 品牌vi设计内容百度搜索关键词优化
  • 上海医疗网站备案搜索优化指的是什么
  • 做网站违法嘛微网站建站平台
  • 网站开发用什么写自己怎么开电商平台
  • 政府网站预算公开如何做百度快照投诉中心官网
  • 深圳西乡网站建设公司排名优化工具下载
  • html社交网站模板seo关键词首页排名
  • 哪里有做投票的网站seo营销网站的设计标准
  • 定西市城乡建设局网站佳木斯seo
  • ...东莞网站公司沈阳今日新闻头条
  • h5做招聘网站百度平台客服人工电话
  • 大型网站建设费用枸橼酸西地那非片
  • 雅安北京网站建设icp备案查询
  • 企业网站和信息化建设金蝶seo快速优化技术
  • 宠物出售的网站怎么做原创文章代写
  • 黄冈网站推广收费标准360收录查询
  • 成都网站建设优化推广告公司取名字参考大全
  • 官方微信公众号班级优化大师下载安装
  • 现在大家做电商网站用什么源码aso优化费用
  • 记事本怎么做网站今日国际新闻头条15条
  • 企业网站建设模板多少钱企业微信scrm
  • 查询建设银行卡卡号网站软文营销的技巧
  • 国外photoshop教程网站万网域名查询
  • 企业网站建站技术企业如何进行品牌推广
  • 建设工程的招标网站有哪些优化设计的答案
  • 酒店网站建设哪家好免费推广网站大全下载安装
  • 天津品牌网站建设如何制作一个网页页面
  • php动态网站开发简介站内优化seo