This is a migrated thread and some comments may be shown as answers.

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

2 Answers 444 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 15 Mar 2016, 11:55 PM

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 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 18 Mar 2016, 07:55 AM

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!
 
0
David
Top achievements
Rank 1
answered on 18 Mar 2016, 10:01 PM

Thanks for source code. It works perfectly.

 

Again thanks

Tags
TreeList
Asked by
David
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
David
Top achievements
Rank 1
Share this question
or