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

EditorActions.addNewRow documentation or sample code #212

Open
diego-inflightvr opened this issue Apr 17, 2018 · 2 comments
Open

EditorActions.addNewRow documentation or sample code #212

diego-inflightvr opened this issue Apr 17, 2018 · 2 comments

Comments

@diego-inflightvr
Copy link

diego-inflightvr commented Apr 17, 2018

Hi Ben,

I'm trying to add a feature that allows the user to create a new child under an specific node (in a tree grid) but I'm not being able to make it.
I'm using the following event handler in for the menu action:
EVENT_HANDLER: ({ metaData }) => {
const rowIndex = metaData.rowIndex + 1
store.dispatch(Actions.EditorActions.addNewRow({
stateKey,
rowIndex,
columns,
data: {
id: "666",
parentId: metaData.rowData._id,
children: [],
name: 'some name',
description: 'some description'
}
}));
}

This code adds a new row but NOT under the parent node (just adds it below it as a sibling) and most importantly, it throws some errors like this one:
image

From debugging I see the problem is that the variable treeData is empty (all its properties are an empty string or null, etc) in the Cell class. In particular, the "depth" prop inside the treeData json is an empty string.

I guess I'm probably doing something wrong in the rest of my code but I couldn't find any example that shows how to add new rows to the grid.
If you have any sample code of this I would really appreciate it...

Thanks in advance!
Cheers

@diego-inflightvr
Copy link
Author

Anyone? I've tried to implement the feature in the tree example grid provided in this repo and I'm facing the same issue...

@Phenixer
Copy link

Phenixer commented Aug 2, 2019

We are facing the same problem. From what I understand, the object in memory has the wrong data format.

We could potentially create our own Action+Reducer and use internals of React-Redux-Grid to build up a new item. I believe the code is not too far from setPartialTreeData in src/reducers/actionHelpers/datasource.js. (which, I think, updates the childrens of a node after a partial load)

Even with that, as soon as I use the inline-editor and save, drag&dropping items in the grid stops working.

The repository hasn't been updated since February, I think I might end up creating my own inline insert state by overriding the row renderer.

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

2 participants