在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ expandedRowKeys每次拿到了,卻不起作用?

expandedRowKeys每次拿到了,卻不起作用?

我每次只展開(kāi)點(diǎn)擊行,其它行自動(dòng)收縮的效果,設(shè)置斷點(diǎn)發(fā)現(xiàn)每次的expandedRowKeys能夠拿到,但仍然能夠展開(kāi)多行,即先點(diǎn)開(kāi)a行,再點(diǎn)開(kāi)b行,b行展開(kāi),但a行仍然展開(kāi),未收縮。


render方法內(nèi):

<Table
    dataSource={this.state.SampleData}
    rowKey={record => record.id || record.key}
    columns={columns}
    onChange={this.handleStandardTableChange}
    pagination={this.state.pagination}
    loading={this.state.loading}
    expandedRowRender={(record) => { return this.state.showListDom[record.id] || null; }}
    onExpand={(expanded, record) => { return this.expandFunction(expanded, record) || null; }}
    expandedRowsKeys={this.state.expandedRowsKeys}
  />


onExpand觸發(fā):

expandFunction = (expanded, record) => {
    const { showListDom } = this.state;
    this.setState({
      newShowList: {},
    });
    const keys = [];// 初始化
    if (record && expanded) {
      keys.push(record.id);
      const param = {
        modelId: record.id,
      };
      this.setState({
        ...this.state,
        param: {
          modelId: record.id,
        },
      });
      this.getExpandData(param, () => {
        const subList = this.state.subData.map((v) => {
          return {
            ...v,
            todo: v.status,
          };
        });
        const dom = (
          <Table
            columns={this.detailsColumns}
            onChange={this.handleSubTableChange}
            dataSource={subList}
            rowKey={subList.id}
            pagination={false}
          />);
        const Id = record.id;
        const item = {};
        item[Id] = dom;
        const newItem = {};
        newItem[Id] = dom;
        this.setState({
          showListDom: {
            ...showListDom,
            ...item,
          },
          expandedRowsKeys: keys,//更新expandedRowKeys
        });
      });
    }
  };
回答
編輯回答
念舊

expandedRowKeys={this.state.expandedRowsKeys}
屬性名寫(xiě)錯(cuò)了

2018年2月4日 11:48