search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Cannot read property 'exp' of undefined

Asked by Richard
7 years ago.

Hi,

Not sure if this is something I'm doing or something with the new sandbox build (Version: 2396)?

TypeError: Cannot read property 'exp' of undefined
    at watchFnToHumanReadableString (<anonymous>:703:19)
    at m.$delegate.__proto__.$watch (<anonymous>:735:28)
    at Object.link (http://localhost:4040/lazyLoad/plugins/DayPilotProJavaScript/daypilot-all.min.js:34:310950)
    at http://localhost:4040/bower_components/angular/angular.min.js:16:71
    at la (http://localhost:4040/bower_components/angular/angular.min.js:81:90)
    at p (http://localhost:4040/bower_components/angular/angular.min.js:66:341)
    at g (http://localhost:4040/bower_components/angular/angular.min.js:58:481)
    at g (http://localhost:4040/bower_components/angular/angular.min.js:58:498)
    at g (http://localhost:4040/bower_components/angular/angular.min.js:58:498)
    at g (http://localhost:4040/bower_components/angular/angular.min.js:58:498)

Lastly, when I remove the scheduler from my page, the page is way faster, but when I add it again, everything is slow and laggy to respond. Any idea why? I've attached a screenshot from Batarang - the code shown is not my own.

Regards,
Richard

Answer posted by Dan Letecky [DayPilot]
7 years ago.

As far as I can tell there is no "exp" property in DayPilot.

It looks like it's related to watching changes of an object that you reference using "config" or "events" attributes.

The slowdown is also related to the Angular "watch" mechanism. The Scheduler needs to watch all changes in those objects ("config" and "events") in order to update itself. If the object tree is large Angular needs much longer time to go through all its properties and sub-properties to detect the changes.

If this is caused by a large "events" array you can also load the events directly using DayPilot.Scheduler object:

dp.events.list = [ ... ];
dp.update();

Angular is very convenient because it can watch object changes for you but comes at a price. When dealing with large data sets there is a point where you have to switch to manual updates.

Let me know if you experience a slowdown event with small data sets.

Comment posted by Richard
7 years ago.

Hi Dan,

Some feedback with regards to the 'exp' error. When I disable Batarang, this problem went away.

Regards,
Richard Bailey

Comment posted by Richard
7 years ago.

Hi Dan,

So I tried using the
dp.events.list = [ ... ];
, but the events are not being added? This is my code:
        function mapAndAddBookingEvents(bookingArgs, flatten) {
            var bookings = flatten ? _.map(bookingArgs, 'Bookings') : bookingArgs;
            var mappedEvents = _.map(flatten ? _.flattenDeep(bookings) : bookingArgs,
                function (item) {
                    var e = {
                        start: new DayPilot.Date(item.FromDate.format(appConfig.alternativeDateFormat))
                            .addHours(vm.config.businessBeginsHour),
                        end: new DayPilot.Date(item.ToDate.format(appConfig.alternativeDateFormat))
                            .addHours(vm.config.businessEndsHour),
                        id: item.Id,
                        resource: item.ResourceID,
                        text: item.Description,
                        bubbleHtml: 'Hours: ' + item.Hours,
                        meta: item
                    };
                    return e;
                });

            vm.scheduler.events.list = [];
            _.forEach(mappedEvents, function (value) {
                vm.scheduler.events.list.push(value);
            });
            vm.scheduler.update();

            vm.config.ventHoverHandling = 'Bubble';
        }

Can you perhaps spot what I'm doing wrong?

Thanks again!
Richard

Comment posted by Richard
7 years ago.

Dan,

Strange thing is, the above code works when I run it from another piece of UI on the page (
ng-change or ng-click
). But when I run it from start-up, it does not populate. I have added the output of the resource list I'm adding to as well as the events list:

Resources: https://postimg.org/image/5d7o4zi8h/
Event List: https://postimg.org/image/4cj0d9gv7/

Thanks

Comment posted by Richard
7 years ago.

Hi Dan,

Another update. So it's definatly something to do with the start and update of the schedular. I have a debugging component, which outputs any JS object in JSON. I have attached the output when the page loads:

https://s10.postimg.org/4wnippsy1/Capture.png

Now, I'll select the same project from a drop-down which will trigger the exact same code to fire - the output:

https://s17.postimg.org/69cshlqin/Capture.png

As you can see, the scheduler.events.list has data. You're probable thinking 21 vs. 2 - why? That's because the one bookingModel (in the vm.activeBookingModels collection) has 11 bookings and the other one 10.

Richard

Comment posted by Richard
7 years ago.

So I think the issue is that setting some settings on vm.config (config="vm.config") and some on vm.scheduler (publish-as="vm.scheduler"), causes issues.

I tried setting everything on vm.scheduler, but when the page loads, it's undefined?

Regards,
Richard

Comment posted by Richard
7 years ago.

Nevermind, I came right... Thanks Dan

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.