TreeList with dynamic binding

2 posts, 0 answers
  1. vlad
    vlad avatar
    1 posts
    Member since:
    Jul 2016

    Posted 20 Jul Link to this post

    Hi!

    I want to create TreeList with custom columns count. There is my code:

    @(Html.Kendo().TreeList<dynamic>()
        .Name("treelist")
        .Columns(columns =>
        {
            foreach (System.Data.DataColumn column in Model.Columns)
            {
                var c = columns.Add().Field(column.ColumnName);
            }
        })
        .Filterable()
        .Sortable()
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("Read", "Home"))
            .Model(m =>
            {
                var id = Model.PrimaryKey[0].ColumnName;
                m.Id(id);
     
                //m.ParentId(); what i should do here???
     
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    var field = m.Field(column.ColumnName, column.DataType);
                    if (column.ColumnName == id)
                    {
                        field.Editable(false);
                    }
     
                }
            })
        )
    )

    HomeController returns:

    public ActionResult Read([DataSourceRequest] DataSourceRequest request)
            {
                DataTable products = DataCache.FullTable;
     
                if (request.Aggregates.Any())
                {
                    request.Aggregates.Each(agg =>
                    {
                        agg.Aggregates.Each(a =>
                        {
                            a.MemberType = products.Columns[agg.Member].DataType;
                        });
                    });
                }
     
                return Json(products.ToDataSourceResult(request));
            }

    I see examples on GutHub, but i don't find anything about dynamic binding.

  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 25 Jul Link to this post

    Hello Vlad,

    We do not have an example of dynamic column binding just yet. The ParentId should be configured to the field that will hold the parent-child relationship -- otherwise the TreeList will only show the root-level items.

    Regards,
    Alex Gyoshev
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top