Show cool things you have done with our products


Post by ohadts »

Hi,

I need a way to completely reset a Gantt. A little background: I'm currently implemented a gantt and render it to a div inside an existing angular project. When the relevant partial view is loaded with the div, a function is being invoke by the controller to run Ext.Microloader (Extjs, manifest and required files is already loaded in the index.html).
So far so good, everything is working fine until this point. Now I need a way to completely remove the gantt, load the data again from the server and render a new gantt to the same div based on the newly arrived data. Lets say the user goes to another view, play around a little bit here and there, and then return to the gantt - I don't want to refresh the page, but I need to get the data again in case something has changed.
I've tried all the destroy method that I could find, but nothing help... every time I try the reload the gantt I get a bunch of error because I have duplicates values, its like I can't get rid of the old data :shock:.
Can someone help ?

Post by Maxim Gorkovsky »

Hello.
Can you provide us more info about erorrs? Call stack, error message? When does the error occur: on first render, after destroy, or when creating new gantt after destroy? Can you provide us runnable test case?
We have tests, destroying gantt, to check if there is a leak and they are green, so destroying should work fine.

Post by ohadts »

OK. I've manged to remove the old data. It was an object on the crudStore i didn't wipe. Now i can recreate the gantt a few times and after a while i get this error:
Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null
in app.js

Maybe you can give me some guidelines what do i need to invoke to perform a clean wipe? And how to create is again from scratch?

Post by Maxim Gorkovsky »

You already doing this right, invoking 'destroy' on gantt. You can try to destroy first crud manager, and then stores. Probably you added listener to store, that can use destroyed instance. Can you provide callstack of that getBoundingClientRect?

Post by ohadts »

I can't provide a callstack for this function because of the error.
Now i invoke the destory method on the crudManager and stores, and then on the Gantt itself.
Do i need to manually clear the listeners, or the destroy method should take care of them?

Post by Maxim Gorkovsky »

Destroy order should be gantt, crud, stores. If you destroy everything you created - listeners should also be destroyed. Take a look into manager listeners which destroy themselves.

Post by ohadts »

Thanks. I'm invoking in the order you specify. Now i have a problem launching the gantt again, i get:
Uncaught Error: Can't find a project calendar in `getProjectCalendar` in "bryntum-gantt-pro/src/Gnt/model/task/More.js" 1517

Maybe i'm doing something wrong when i initiate the gantt?

Post by Maxim Gorkovsky »

Hard to tell without seeing a code. How do you destroy/create gantt? Can you reproduce it in our example?

Post by ohadts »

This is a very big project... so its hard to know what to copy here. But anyway, i have "loadData" function, when the function end all the stores and crudManager is setup and available. now i have another function "loadView", it doing some stuff, and at the end:
me.mainView = me.getMainViewportView().create({
            viewModel: {
                type: 'advanced-viewport',
                data: {
                    crud: me.crudManager,
                    undoManager     : me.undoManager,
                    taskStore: me.crudManager.getTaskStore(),
                    calendarManager: me.crudManager.customCalendarManager,
                    currentLocale: me.currentLocale,
                    availableLocales: me.getLocalesStore(),
                    availableSimulations: availableSimulations,
                    hasChanges: true,
                    readOnlyMode: false,
                }
            },

            columns: columns,
            needAdjustToCalendar : needAdjustToCalendar,
            crudManager: me.crudManager,
            startDate: this.startDate,
            endDate: this.endDate,
            title: title,
            renderTo: 'gantt-container'
        });
When the page load everything is fine If i invoke "destroy" (by calling myApp.app.mainView.destroy()) on this view, the next time i invoke "loadView" i get an error:
Uncaught TypeError: Cannot read property 'rendered' of null in
bryntum-gantt-pro/src/Gnt/plugin/ConstraintResolutionGui.js : 40

I need a way to completely remove and then recreate this view.

Post by ohadts »

Or maybe just to refresh the data and leave the view as is...

Post Reply