react-component / react-component/table

onCell, onHeaderCell not working

Open
#506 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.4k
Forks
618
Avg merge
10h 19m
Merged PRs (30d)
2

Description

rc-table version: 7.7.2

issue 1:

onCell={(record, index) => {
  return {
    onClick: () => {
      console.log('click');
    },
  };
}}
onHeaderCell={(column) => {
  return {
    onClick: () => {
      console.log('click');
    },
  };
}}

I add those code to the Table components, but i can't see the click output.

issue 2:

If i customize the table components, like bellow, then i add some customize property

const SelfCell= (props: any) => {
  console.log(props);

  return <th {...props} />;
};

const components = {
  header: {
    cell: SelfCell,
  },
  body: {
    cell: SelfCell,
  },
};

onCell={(record, index) => {
  return {
    test: index
  };
}}
onHeaderCell={(column) => {
  return {
    test: column
  };
}}

After the cell renderd, I can't see the 'test' property be output in the props.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how onCell and onHeaderCell are handled when rendering header and body cells, then compare that path with the custom components example. Verify the click handlers are attached and that returned properties such as test reach SelfCell props; the issue is resolved when both behaviors work.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.