Giter Site home page Giter Site logo

Comments (5)

JIACHENG9 avatar JIACHENG9 commented on August 20, 2024 1

你是想在 Table 使用 sorter 访问后台?比如 https://ant.design/components/table-cn/#components-table-demo-ajax

这个场景不适用于 useFormTable。useFormTable 是用于表单作为查询条件,进行搜索,之后请求后台,Table 展示。而问题的需求是想不通过 Form 作为查询条件,而是通过 Table 来作为查询条件去请求后台。

在业务里,要是有 Form,又在 Table 里去做查询是不推荐的,FormTable 比 在 Table 里做 sorter 及 filter 更好的地方在于回填及以及更多的搜索条件。

那需要有什么方式来做?

  1. 使用 useFormTable,sorter 及 filter 只是后台查询的条件,在 Form 中加 Select 即可,而不使用 Table 的 sorter 及 filter
import { Select } from 'antd';
const {Form, Table} = useFormTable(config);

<Form>
  <Form.Item name="sorted">
    <Select>
      <Select.Option value="1">sorter 1</Select.Option>
      <Select.Option value="2">sorter 2</Select.Option>
    </Select>
  </Form.Item>

  <Form.Item name="filter">
    <Select>
      <Select.Option value="1">filter 1</Select.Option>
      <Select.Option value="2">filter 2</Select.Option>
    </Select>
  </Form.Item>
</Form>
  1. 加一个场景,比如 useRemoteTable 的场景。(需要在 sunflower 加上)
const { Table }  = useRemoteTable({
  sorter: () => Promise,
  filter: () => Promise,
});

<Table />

from sunflower.

lencx avatar lencx commented on August 20, 2024

好的,谢谢了。确实是想在Table使用sorter访问后台,尝试了很多方法,行不通,就来请教一下。

from sunflower.

JIACHENG9 avatar JIACHENG9 commented on August 20, 2024

@lencx 是很通用的需求,会加上一个 useRemoteTable

from sunflower.

lencx avatar lencx commented on August 20, 2024

嗯嗯,谢谢了

from sunflower.

JIACHENG9 avatar JIACHENG9 commented on August 20, 2024

@lencx [email protected]

import { useFormTable } from 'sunflower-antd';

useFormTable({
  search({ currentPage, pageSize, filters, sorter, ...formValues })
})

from sunflower.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.