DHTMLX / gantt

GPL version of Javascript Gantt Chart
https://dhtmlx.com/docs/products/dhtmlxGantt/
GNU General Public License v2.0
1.5k stars 328 forks source link

TypeError: Cannot read property '$config' of undefined #70

Closed tarokobear closed 1 year ago

tarokobear commented 3 years ago

For DHTMLX Gantt: Version 7.1.2, Standard Edition

When I execute: gantt.parse(tasks);

The console shows the following error: TypeError: Cannot read property '$config' of undefined

The error occurs at this section of the code

line: 13213

 for (var i = 0; i < verticalViews.length; i++) {
          for (var j = 0; j < horizontalViews.length; j++) {
            **if (verticalViews[i].$config.id && verticalViews[j].$config.id && verticalViews[i].$config.id === verticalViews[j].$config.id) {**
              commonViews.push(verticalViews[i].$config.id);
            }
          }
        }

The verticalViews array goes out of bounds when using the horizontalViews' index j.

The layout that we are using is:

gantt.config.layout = {
                    css: "gantt_container",
                    rows: [
                        {
                            cols: [
                                {view: "grid", id: "grid", group: "grids", scrollX: "scrollHor", scrollY: "scrollVer"},
                                {resizer: true, width: 1},
                                {view: "timeline", id: "timeline", scrollX: "scrollHor", scrollY: "scrollVer"},
                                {view: "scrollbar", id: "scrollVer"}
                            ]
                        },
                        {resizer: true, width: 1},
                        {
                            cols: [
                                {view: "grid", group: "grids", bind: gantt.config.resource_store, config: resourceGridConfig, scrollX: "scrollHor", scrollY: "resourceVScroll"},
                                {resizer: true, width: 1},
                                {view: "timeline", bind: gantt.config.resource_store, layers: resourceLayers, scrollX: "scrollHor", scrollY: "resourceVScroll"},
                                {view: "scrollbar", id: "resourceVScroll"}
                            ]
                        },
                        {view: "scrollbar", id: "scrollHor"}
                    ]
                };
iadaz commented 3 years ago

Also seeing a similar issue within trial of 7.1.3 Pro in the "scrollTo" function. Same issue, length of one array is used as index into a smaller array.

I changed a bunch of things trying to fix it, I think removing the scrollX: "scrollHor" from the first col of the first row fixed it for me.

I was using the config from an old version so I'm not sure if something was deprecated.

gearcoded commented 3 years ago

@tarokobear and @iadaz, we are aware of that issue. It occurs because the scrollbar is attached to more than 2 views. If you set a different name, the issue shouldn't occur:

http://snippet.dhtmlx.com/5/a20ef712b

The dev team will fix that bug in the future, but I cannot give you any ETA.

gearcoded commented 2 years ago

@tarokobear and @iadaz, The dev team fixed the bug for the scrolbar if it is attached to 3 or more views: https://docs.dhtmlx.com/gantt/whatsnew.html#719 You can see that the issue is no longer reproduced in the following sample: https://snippet.dhtmlx.com/5/6aecbdfdc