问题
I'm facing a problem to integrate breeze.js and kenoui grid . I have an observable array in my view model , I fill this array calling ajax operation . when I wire the array to the grid I get an exception "Maximum call stack exceeded" . I read a post that the grid has a problem with the entityacpect inside breeze.js entity. Is there any hot fix for this problem , or any other suggestion.
Thanks in advance ...
回答1:
This is a standard circular reference javascript serialization issue. It is not a Breeze specific issue.
Circular references are a natural feature of entity models. Consider a Customer.Orders property that returns the customer's orders and each order has a Order.Customer navigation property to get back to its parent customer. This is to be expected and will result in an error like the one you experienced when trying to serialize such a graph unless you manage the serialization explicitly.
You can even get a circular reference problem with a Breeze entity that has no circular navigation paths. The difficulty stems from the fact that every Breeze entity has an inherent circularity by way of its entityAspect property:
This kind of circular reference is NOT an issue for Breeze if you go thru the Breeze EntityManager.executeQuery or EntityManager.saveChanges methods because Breeze automatically handles the serialization process for you, however if you bypass these methods, which you have presumably done, then you have to manage the serialization yourself.
So you have two approaches.
1) Use EntityManager.executeQuery to perform your ajax operation. Almost any endpoint can be reached via this method.
2) Read the following article ( it's about knockout but the issues are the same) and manage your serialization explicitly: http://www.breezejs.com/documentation/knockout-circular-references
来源:https://stackoverflow.com/questions/19860110/maximum-call-stack-exccedwith-using-kendoui-grid-and-breeze-js