Maximum call stack size exceeded error and angularjs with asp.net mvc

3 posts, 0 answers
  1. David
    David avatar
    4 posts
    Member since:
    Nov 2014

    Posted 15 Mar 2016 Link to this post

    Hello,

    I use last version of kendo ui library with angularjs and asp.net mvc 5 on server.

    If I use remote data binding kendo.all.js return Maximum call stack size exceeded error.

    Whats wrong?

    Thanks

    controller:

    public class TestController : Controller
    {
     
      [HttpGet, Route("category-tree")]
      public ActionResult TreeListCategories([DataSourceRequest] DataSourceRequest request)
      {
        var allCategories = new List<CategoryModel> {
          new CategoryModel {Id = 1, Name = "First", ParentCategoryId = null},
          new CategoryModel {Id = 2, Name = "Second", ParentCategoryId = 1},
          new CategoryModel {Id = 3, Name = "Third", ParentCategoryId = 2},
          new CategoryModel {Id = 4, Name = "Fourth", ParentCategoryId = 3},
        };
     
        var result = allCategories.ToTreeDataSourceResult(request);
        return Json(result, JsonRequestBehavior.AllowGet);
     
      }
     
      public class CategoryModel
      {
        public int? Id { get; set; }
        public string Name { get; set; }
        public int? ParentCategoryId { get; set; }
      }
     
    }

     

    html code :

    <kendo-tree-list k-options="treelistOptions"></kendo-tree-list>

    angular js code :

     

    $scope.treelistOptions = {
           dataSource: {
             type: "aspnetmvc-ajax",
             transport: {
               read: {
                 type:'GET',
                 url: 'category-tree',
               }
             },
             schema: {
               model: {

                 Id: "categoryId",

                 ParentId:"parentCategoryId",
                 fields: {
                   categoryId: { field: "categoryId", type: "number", nullable: false },
                   parentCategoryId: { field: "parentCategoryId", nullable: true },
                   name: { field: "name" },}
               }
             }
           },
           columns: [
            { field: "Name" },
           ],
         };

     

  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2286 posts

    Posted 18 Mar 2016 Link to this post

    Hello David,

     

    There are few errors I see in the configuration:

     

    1. The model field definition is not correct - the names of the fields are not the same as the ones send from the server

     

    2. schema.model.id as well as schema.model.parentId are preserved conflagration options and the casing is important. It is not correct in your setup

     

    3. schema.data should be configured to the "Data" field from the response otherwise the DataSource will not properly read data 

     

    I'm attaching an application assembled based on your code snippets. The important bits are in the HomeController and Angular view.

     

     

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. David
    David avatar
    4 posts
    Member since:
    Nov 2014

    Posted 18 Mar 2016 in reply to Nikolay Rusev Link to this post

    Thanks for source code. It works perfectly.

     

    Again thanks

Back to Top