Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler on adding calendar entry causes Maximum call stack size exceeded #3

Open
ganySA opened this issue Dec 4, 2015 · 20 comments

Comments

@ganySA
Copy link

ganySA commented Dec 4, 2015

Firstly this is such a fantastic library - thank you.

When i use the library. Updates and Deletes seem to work correctly however adding an item to the scheduler using the template form causes the same Maximum call stack size exceeded error that one normally gets when using breeze without this library.

Is adding items supported? i have tried to debug the library but i am not getting very far in determining where the problem may be.

Any suggestions?

@pascalberger
Copy link
Contributor

This should work, I'm using it too to add items with the default form.

Which DataSource are you using? You need to use the kendo.data.breeze.SchedulerSource and useBreezeMapping should be kept set to true (default value).

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

Hi

I am using both of those... do you know if this works with GUID data type?

I am trying to work out what else might be different from the standard example.

thanks

@pascalberger
Copy link
Contributor

I never used it with GUID data types. But not sure if this is even an issue with the datasource or if it is with Kendo controls.

Which version of the Kendo controls are you using (I haven't used it with anything newer than 2015.1.429)? Also you can try to debug: Useful breakpoints might be here (for reading) and here for creating a new item.

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

Some more info: I am using a GUID as a primary key when i click on the scheduler to add it, it throws an exception:

Uncaught Error: Cannot attach an object of type (Appointment:#MedDev.Entity) to an EntityManager without first setting its key or setting its entityType 'AutoGeneratedKeyType' property to something other than 'None'

So i added the following:

 var appType = manager.m.metadataStore.getEntityType("Appointment");
 appType.setProperties({ autoGeneratedKeyType: breeze.AutoGeneratedKeyType.Identity 

This autogenerates the key which i can see happening. However i am not sure why when i click the save button on the template form it just causes the stack error.

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

I am using the latest version of kendo ui....2015.3.1111

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

what is strange is that

  1. Read works 100% i can see the scheduler populated
  2. Delete works 100%
  3. Change works 100%

Something on add seems to be broken.

@pascalberger
Copy link
Contributor

Can you debug to check when the exception is thrown on creating an item and who is creating it (Kendo, the DataSource or Breeze)? And what exactly is the exception?

For example the Cannot attach an object of type exception had nothing to do with this DataSource but was a configuration error in Breeze as you found out.

Are you reaching the create breakpoint or is the exception thrown before?

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

Ok...

This is what i can see:

  1. When i click the scheduler it opens up the template to capture an event at which point i can see the breakpoint on (this executes correctly and it seems the entity is actually created)
                    case 'add':
                        ev.items.forEach(function (item) {
                            var entity = manager.createEntity(typeName || query.resourceName, item);
                            manager.addEntity(entity);
                            syncItems(item, entity, useBreezeMapping, breezeEntityMapping);
                        });
                        break;
  1. Then i populate the form. I then click on the save button. and i have attached to the "save" event of the scheduler and i can see the event is populated correctly.
  2. Then it looks like the code jumps into Kendo UI and simply throws the below

RangeError: Maximum call stack size exceeded
at EnumSymbol.toString (native)

It never reaches the create method - so no server request is ever sent

@pascalberger
Copy link
Contributor

Can you check if after the case 'add' the entities in ev.items still contain circular properties (eg. entityAspect, etc)?

syncItems should take care of that as it does after reading the items.

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

No these all seem to be removed.....

@pascalberger
Copy link
Contributor

Unfortunately running out of ideas. Removing circular properties from breeze entities is the main job of the data source, and this seems to work fine.

I assume Telerik has changed something in Kendo in one of the newer versions. Maybe you can try your luck with the Telerik support (even though they are usually not really helpful for this kind of stuff).

@ganySA
Copy link
Author

ganySA commented Dec 4, 2015

Hi

So i have tried pretty much everything even using an extremely simple database table and this still seems to break.

Maybe its the newer version of kendo.

@ganySA
Copy link
Author

ganySA commented Dec 5, 2015

Hi Pascal

It seems that the error is thrown at:

   create: function (options) {
                var handleError = this._handleError;

                this._saveChanges().then(
                        function (saveResult) {
                            options.success(saveResult.httpResponse);
                        }
                    ).catch(
                        function (error) {
                            handleError(options, error);
                        }
                    );
            },

on the line :

options.success(saveResult.httpResponse);

When i look inside the saveResult object there is a data object. that data object contains circular properties such as entityAspect etc.

This then causes kendo to fail.... any idea how i could strip them out?

@ganySA
Copy link
Author

ganySA commented Dec 5, 2015

I have changed:

options.success(saveResult.httpResponse);

to:

options.success();

And that seems to be ok.... i will continue testing...

@pascalberger
Copy link
Contributor

Have you changed something else since you stated before that the create method is never called and the exception is thrown before?

@pascalberger
Copy link
Contributor

The scheduler dialog is still closed if you call options.success() without passing the HTTP response object? The change was introduced with this committ to notify Kendo about success / failure of the request which is for example required to have the Kendo Scheduler close the Edit form. Maybe we should just don't pass the HTTP response object, at lest in success case.

@ganySA
Copy link
Author

ganySA commented Dec 5, 2015

Hi

The form does close and the record is saved.

But now there is another issue. Only fields with the same name as kendo scheduler fields are saved back to the database...

So for example my database field name is StartDate not start, so it does not save this data to the database....?

For reading data from the database it seems to work fine... but saving it to the entity object breaks..

Do you know where/how i can access the entity object linked to the form so that i can populate it manually?

@ganySA
Copy link
Author

ganySA commented Dec 5, 2015

i have a little example my schema mapping is as follows:

        schema: {

            model: {
                id: "taskId",
                fields: {
                    taskId: { from: "appointments_ID" },
                    title: { from: "subject", defaultValue: "No title", validation: { required: true } },
                    start: { type: "date", from: "startDate" },
                    end: { type: "date", from: "endDate" },

                }
            }
        },

I also have an additional field called description which i dont map because its exactly the same.

only description field is saved to the database.

@pascalberger
Copy link
Contributor

Sorry, I'm not really familiar with all this stuff. If you need helpto map the fields you should ask the Breeze guys.

If you want to bind different fields to the form, you should check with Teleriks support. I assume you would need to change the template of the form. In this case you also might need to make sure that the fields are properly initialized on creating a new model (as done here for the default fields)

@ganySA
Copy link
Author

ganySA commented Dec 5, 2015

When i read the database it maps the fields correctly to because i am using telerik schema property.
When i try save back... it only saves the fields as per the normal template and ignore the schema mapping.... so breeze doesnt get update based on the telerik schema option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants