Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onRowClick 获取不到数据 #408

Open
web3creator opened this issue Mar 6, 2023 · 1 comment
Open

onRowClick 获取不到数据 #408

web3creator opened this issue Mar 6, 2023 · 1 comment

Comments

@web3creator
Copy link

web3creator commented Mar 6, 2023

Versions

package version
react 16.8.6
rsuite-table 5.9.0
import { TREE_DEPTH } from 'rsuite-table/src/constants';

  let Child = React.memo(() => {

.....
    return (
      <div>
        <Table
          isTree={true}
          virtualized
          showHeader={false}
          height={props.viewState.height}
          rowKey="value"
          data={data}
          shouldUpdateScroll={false}
          defaultExpandAllRows
          onRowClick={(rowData) => {
            console.log(rowData);

      /// 为什么我这里获取不到数据呢?这个使用有什么讲究吗,大佬
            console.log(rowData[TREE_DEPTH])
          }}
        >
          <Column flexGrow={1} >
            <HeaderCell >label</HeaderCell>
            <Cell dataKey="label" />
          </Column>
          <Column width={100}>
            <HeaderCell>comment</HeaderCell>
            <Cell dataKey="price" />
          </Column>
        </Table>
      </div>
    );
  })
  return (<Child />);

-->

@simonguo
Copy link
Member

simonguo commented Mar 8, 2023

你取的 TREE_DEPTH 是 rsuite-table/src/constants 目录下的 Symbol ,和你使用 Table 使用的不是同一个 Symbol 。

  • 你如果是采用的 ESM(ESModule) 应该使用 rsuite-table/es/constants 里的 TREE_DEPTH
  • 如果用的是 CJS(CommonJS) 则使用 rsuite-table/lib/constants 里的 TREE_DEPTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants