We use Bryntum Grid with Vue3 and Vite.
The grid is configured as :
const store = new AjaxStore({
id: 'storeAllgemein',
modelClass: WorktimesheetViewAllgemeinModel,
readUrl: `${API_BASE_URL}/read/view/an/allgemein/`,
autoLoad: true,
tree: true,
lazyLoad: { chunkSize: 1000 },
filterParamName: 'anfilter',
encodeFilterParams: encodeFilterParams,
});
We have added click-handler on each row triggering backend actions with complex business logic updating rows within the currently open sub-node of our tree-store.
In order to reflect the updates of the backend business logic we want to refresh the content of the currently open sub-node. We do this by calling:
const row = gridConfig.value.store.getById(worktimesheetId);
// worktimeSheetId is the store's id of a row within the sub-node
const parent = row.parent;
parent.clearChildren(true);
gridConfig.value.store.loadChildren(parent);
So far all is fine. Works perfectly.
However we also provide a form input field in our UI where a user can enter a search word (newValue) which updates the complete tree grid by calling:
store.filter({
property: 'nodeLabel',
value: newValue,
disabled: false
});
Before we had introduced our sub-tree-refresh feature (as described above) filtering worked perfectly.
But now the respective sub-node for which we had called clearChildren / loadChildren is "damaged".
clicking on the arrow to open such a sub-node no longer opens such a sub-node
after clicking on the arrow we observe store.isLoading = true
We see the exceptions below
Exceptions we had seen (==> shows the line throwing error):
@bryntum_grid.js?v=27d563a1:29290 Uncaught TypeError: Cannot read properties of undefined (reading 'includes')
at AjaxStore.onNodeRemoveChild (@bryntum_grid.js?v=27d563a1:29290:29)
at @bryntum_grid.js?v=27d563a1:18242:19
at Array.forEach (<anonymous>)
at ModelClass.clearChildren (@bryntum_grid.js?v=27d563a1:18240:16)
at AjaxStore.clear (@bryntum_grid.js?v=27d563a1:24885:25)
at DynamicTreeStoreLazyLoadPlugin.clearLoaded (@bryntum_grid.js?v=27d563a1:33448:12)
at DynamicTreeStoreLazyLoadPlugin.load (@bryntum_grid.js?v=27d563a1:33693:12)
at gridUtils.js:139:36
onNodeRemoveChild(parent, children, index, flags = { isMove: false, silent: false, unfiltered: false }) {
const me = this, { storage } = me, toRemoveFromUI = [], toRemove = [], { isMove, silent, unfiltered } = flags, removeUnfiltered = unfiltered && me.isFiltered, childrenToRemove = removeUnfiltered && parent.unfilteredChildren ? parent.unfilteredChildren : children;
me.collectDescendants(childrenToRemove, toRemoveFromUI, toRemove, { inCollapsedBranch: !(parent.isExpanded(me) && parent.ancestorsExpanded(me)), unfiltered: removeUnfiltered });
if (!isMove) {
for (const record of children) {
record.unjoinStore(me);
}
for (const record of toRemove) {
==> if (record.stores.includes(me)) {
record.unjoinStore(me);
}
if (me.added.includes(record)) {
me.added.remove(record);
} else if (!record.isLinked) {
me.removed.add(record);
}
}
me.modified.remove(toRemove);
}
if (toRemoveFromUI.length) {
@bryntum_grid.js?v=27d563a1:100893 Uncaught TypeError: Cannot read properties of null (reading 'record')
at Tree.onElementClick (@bryntum_grid.js?v=27d563a1:100893:34)
at functionChainRunner (@bryntum_grid.js?v=27d563a1:12579:23)
at plugInto.<computed> [as onElementClick] (@bryntum_grid.js?v=27d563a1:12555:43)
at Grid.onHandleElementClick (@bryntum_grid.js?v=27d563a1:107170:14)
at Grid.onHandleElementClick (@bryntum_grid.js?v=27d563a1:108869:13)
at Grid.handleEvent (@bryntum_grid.js?v=27d563a1:107003:55)
at HTMLDivElement.handler (@bryntum_grid.js?v=27d563a1:8131:72)
/**
* Called when user clicks somewhere in the grid. Expand/collapse node on icon click.
* @private
*/
onElementClick(event) {
const me = this, target = event.target, cellData = me.client.getCellDataFromEvent(event), clickedExpander = target.closest(".b-tree-expander");
if (clickedExpander) {
event.preventDefault();
}
if (clickedExpander || me.expandOnCellClick && (cellData == null ? void 0 : cellData.record.isParent)) {
==> me.toggleCollapse(cellData.record);
}
}