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

table API 'expandIcon' not working #751

Closed
1 task done
oagsate opened this issue May 6, 2019 · 6 comments
Closed
1 task done

table API 'expandIcon' not working #751

oagsate opened this issue May 6, 2019 · 6 comments

Comments

@oagsate
Copy link

oagsate commented May 6, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

undefined

Environment

windows10, chrome 73.0.3683.103, vue 2.6.6, ant-design-vue 1.3.5

Reproduction link

Edit on CodeSandbox

Steps to reproduce

In App.vue, method 'expandIcon' never runs.

What is expected?

change the expand icon

What is actually happening?

The doc says that adding the 'expandIcon' prop can change the expand icon, but it doesn't really work.
I've checked the components/table/interface.js, and there isn't 'expandIcon' in TableProps. When I added it('expandIcon: PropTypes.func') in , it worked.
So is it just forgotten or there is some other reason?

@tangjinzhou
Copy link
Member

You can submit pr directly.
Now you can use slot="expandIcon" slot-scope="props" instead it.

@PatrickJS
Copy link

I also need this.

@Shawn1
Copy link

Shawn1 commented Jul 22, 2019

Hello tangjinzhou,

I hava tried in Chrome with ant-design-vue 1.3.10, "expandIcon" still cannot work by use slot.

<a-table
:columns="columns"
:dataSource="data" :rowSelection="rowSelection"

AAA

Could you help me?
Thank you

@hex1984
Copy link

hex1984 commented Jul 30, 2019

"expandIcon" still cannot work by use slot.

@EmiyaYang
Copy link

EmiyaYang commented Nov 10, 2019

Workaround by JSX.

BTW, using 'children' as the key to render sub-table's dataSoure may cause weird behaviour and that's why I use 'children2' instead.

const columns = [ { title: "A", dataIndex: "A" }];

const tableData = [{ key: 1, A: 1, children2: [ { key: 11, A: 2} ]}, { key: 2, A: 1, children2: [] }];

export default {
  data() {
    return {
      tableData,
      columns,
      loading: false,
      expandedRowKeys: []
    };
  },
  methods: {
    getExpandIcon({ expanded, record, onExpand }) {
      if (!record.children2 || !record.children2.length) return "";
      return (
        <a-icon
          type={expanded ? "minus-square" : "plus-square"}
          {...{
            on: {
              click: onExpand.bind(this, [expanded, record])
            }
          }}
        />
      );
    }
  },
  render() {
    return (
      <a-spin  spinning={this.loading}>
        <a-table
          columns={this.columns}
          dataSource={this.tableData}
          expandedRowKeys={this.expandedRowKeys}
          expandIcon={this.getExpandIcon}
          {...{
            on: {
              expandedRowsChange: (val) => this.expandedRowKeys = val;
            }
          }}
          scopedSlots={{
            expandedRowRender: record => {
              if (!record.children2 || !record.children2.length) return "";

              return (
                <a-table
                  columns={columns}
                  dataSource={record.children2}
                  pagination={false}
                ></a-table>
              );
            }
          }}
        />
      </a-spin>
    );
  }
};

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants