ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
92.45k stars 49.71k forks source link

如果数据是带children的,渲染到table后,删除行bug #13510

Closed jilieryuyi closed 5 years ago

jilieryuyi commented 5 years ago

关键代码:

deleteItem = (row) => {
      console.log("delete", row);
      let data = this.state.attrs;//[...this.state.attrs];
      let api = "";
      if (/*children*/row.group_id) {
          // juest delete a children node
        api = apiWrapper(API_ATTR_ENTRY_DELETE, {id: row.id});
        for (let key in data) {
            if (data[key].id === row.group_id) {
                data[key].children = data[key].children.filter(v => v.id !== row.id);
                break;
            }
        }
      } else {
          // parent
          // delete parent node will delete all the children node of it
          api = apiWrapper(API_GROUPS_DELETE, {id: row.id});
          data = data.filter(v => v.id !== row.id)
      }

      fetch(api, {method: "POST"});
      console.log(data);
      this.setState({
          attrs: data,
          total: data.length,
      })
  };

确认数据没有错误,出现了重复行! 截图: selection_618

ant-design-bot commented 5 years ago

Hello @jilieryuyi, your issue has been closed because it does not conform to our issue requirements. Please use the Issue Helper to create an issue, thank you!

你好 @jilieryuyi,为了能够进行高效沟通,我们对 issue 有一定的格式要求,你的 issue 因为不符合要求而被自动关闭。你可以通过 issue 助手 来创建 issue 以方便我们定位错误。谢谢配合!