Current filter:
                                You should refresh the page.
                                  • If the dxTreeList.dataStructure option is set to "tree", and the editing option is enabled, the "E4009 - Data item cannot be found" error occurs while trying to edit child items. Here is a sample page illustrating this error. It indicates that the specified key is not found even if the key is present in data and correct. This can be confusing. The cause of this issue is that TreeList editing does not work with hierarchical data. Refer to this documentation page. Currently, our dataSource can't perform the create, edit and delete operations on hierarchical data, so it throws the E4009 error.


                                    If you need to edit hierarchical data using TreeList, implement the CustomStore's insert, remove, and update methods manually. For instance:
                                    [JavaScript]
                                    var dataKey = "Full_Name"; function findItem(items, key, withIndex) { var item; for (var i = 0; i < items.length; i++) { item = items[i]; if (item[dataKey] === key) { return withIndex ? { item, items, index: i } : item; } item = item.items && findItem(item.items, key, withIndex); if (item) { return item; } } } $("#employees").dxTreeList({ dataSource: { key: dataKey, load: function () { return employees; }, insert: function (values) { var parentItem = findItem(employees, values.Parent_ID); delete values.Parent_ID; if (!parentItem) { employees.push(values); } else { parentItem.items = parentItem.items || []; parentItem.items.push(values); } }, update: function (key, values) { var item = findItem(employees, key); if (item) { Object.assign(item, values); } }, remove: function (key) { var itemWithIndex = findItem(employees, key, true); if (itemWithIndex) { itemWithIndex.items.splice(itemWithIndex.index, 1); } } }, dataStructure: "tree", keyExpr: dataKey, itemsExpr: "items", parentIdExpr: "Parent_ID", .... editing: { mode: "cell", allowAdding: true, allowUpdating: true, allowDeleting: true }, ... });
                                    In this example, the findItem function is used to get the current item to update or remove it, or get the parent item of the newly inserted item.

                                    You can review the full code on GitHub and CodePen.

                                0 Solutions

                                Creation Date Importance Sort by