TreeList with dynamic binding

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

    Posted 20 Jul 2016 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
    2527 posts

    Posted 25 Jul 2016 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. John Ah Loo
    John Ah Loo avatar
    11 posts
    Member since:
    Dec 2018

    Posted 30 Apr in reply to Alex Gyoshev Link to this post

    Hi Alex,

    I am also looking for the same solution, Where loading tree list from the dynamic object.

    Can i check if there is any update on the above original question. Thank you.

     

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2043 posts

    Posted 01 May Link to this post

    Hello,

    I already replied in your support ticket thread. In order to avoid any confusions I would suggest to continue the discussion in the support thread. 

    Regards,
    Boyan Dimitrov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top