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

Adding a new row with the same name as an existing row causes the grid to override the current row. #8131

Closed
Maddy-O opened this issue Jun 25, 2024 · 4 comments

Comments

@Maddy-O
Copy link

Maddy-O commented Jun 25, 2024

#8097

@sabahang For better reference, I am attaching a short video about what I want to achieve. In this video, I am trying to add a new row, ABL, which is already present in the grid. The first time I add the row, it overrides the data. The second time, it adds the row. The third time, it does not add the row, but on the fourth attempt, it adds the row again. This random behavior is a bit confusing.

add-row-issue.1.mp4

Here is a plnkr live example for adding new row - https://codesandbox.io/p/sandbox/org-hierarchy-forked-khpt4x?file=%2Fsrc%2Findex.tsx%3A69%2C27

I would greatly appreciate any guidance or instructions on how to implement this feature effectively.

@sabahang
Copy link

sabahang commented Jul 8, 2024

Hi @Maddy-O

In Tree Data structure, getDataPath() should return a unique value for each row. If you would like to add a row with the same data you would have to get the grid to use a different display value. In your case you could use "field" as a display name.

See the following example:
https://codesandbox.io/p/sandbox/org-hierarchy-forked-nht76h?file=%2Fsrc%2Findex.tsx

Hope this helps. Please close the issue if this answer resolves your issue

@netnr
Copy link

netnr commented Jul 23, 2024

I also encountered the same problem. There was no warning in the previous version. Of course, the data was also unique.

@sabahang
Copy link

As I mentioned previously the issue here is that you are using the same key for the new record. The correct behaviour is that the new data shouldn't be added and you would see a warning in console if you try to add a record with same key returned from getDataPath. So the value replacement you are witnessing is a bug we are working on but nonetheless in your scenario the new record should not be added.

We have an internal ticket for changing this behavior so that neither the replacement nor adding would happen

@netnr
Copy link

netnr commented Jul 30, 2024

[
  {
    "MenuId": 66282708992000,
    "MenuPid": 0,
    "MenuName": "仪表盘",
    "$dataPath": [
      "66282708992000"
    ]
  },
  {
    "MenuId": 66987521585152,
    "MenuPid": 66987169697792,
    "MenuName": "系统菜单",
    "$dataPath": [
      "66987169697792",
      "66987521585152"
    ]
  },
  {
    "MenuId": 66987789955072,
    "MenuPid": 66987169697792,
    "MenuName": "系统日志",
    "$dataPath": [
      "66987169697792",
      "66987789955072"
    ]
  },
  {
    "MenuId": 66987169697792,
    "MenuPid": 0,
    "MenuName": "系统管理",
    "$dataPath": [
      "66987169697792"
    ]
  }
]

image

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

3 participants