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

Remote Binding not appears expand node icon

9 Answers 66 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Dario
Top achievements
Rank 1
Veteran
Dario asked on 18 Jun 2020, 04:33 PM

I'm using remote binding, but not appears arrow to expand node.

This is method

public JsonResult Read_DropDownTreeNewCustomerCategoriesData(string Code)
        {
            var result = GetHierarchicalNewCustomerCategoryData()
                .Where(x => !string.IsNullOrEmpty(Code) ? x.ParentCode == Code : x.ParentCode == null)
                .Select(item => new
                {
                    Code = item.Code,
                    Name = item.Name,
                    hasChildren = item.HasChildren
                });
 
            return Json(result.ToList());
        }

This is control

@(Html.Kendo().DropDownListFor(model=>model.NewCustomerCategoryCode)
                        .DataTextField("Name")
                        .DataValueField("Code")
                        .DataSource(dataSource => dataSource
                            .Read(read => read
                                .Action("Read_DropDownTreeNewCustomerCategoriesData", "ListBox")
                            )
                        )
                    )

 I attached result

9 Answers, 1 is accepted

Sort by
0
Dario
Top achievements
Rank 1
Veteran
answered on 18 Jun 2020, 04:35 PM

this is the model

public class NewCustomerCategory
    {
        public string Code { get; set; }
        public string ParentCode { get; set; }
        public string Name { get; set; }
 
        public bool HasChildren { get; set; }
 
    }

this is a provider

public IList<NewCustomerCategory> GetHierarchicalNewCustomerCategoryData()
        {
            var newCustomerCategories = from rec in _context.DimensionValues
                                        where rec.DimensionCodeFK == "CAT.CLIENTE NUOVO"
                                        && rec.DimensionValueType != 4
                                        orderby rec.Code, rec.Indentation
                                        select rec;
 
            var result = new List<NewCustomerCategory>();
 
            foreach (var item in newCustomerCategories.Where(dv => dv.Indentation == 0 && dv.DimensionValueType == 3))
            {
                var newItem = new NewCustomerCategory();
 
                newItem.Code = item.Code;
                newItem.Name = item.Name;
                newItem.ParentCode = null;
                newItem.HasChildren = false;
 
                //Secondo livello
                foreach (var item2 in newCustomerCategories.Where(dv => dv.Code.StartsWith(newItem.Code.Substring(0,1).ToString()) && dv.Indentation == 1 && dv.DimensionValueType == 3))
                {
                    var newItem2 = new NewCustomerCategory();
 
                    newItem2.Code = item2.Code;
                    newItem2.Name = item2.Name;
                    newItem2.ParentCode = newItem.Code;
                    newItem2.HasChildren = false;
 
                    newItem.HasChildren = true;
 
                    //Terzo livello
                    foreach (var item3 in newCustomerCategories.Where(dv => dv.Code.StartsWith(newItem2.Code.Substring(0, 3).ToString()) && dv.Indentation == 2 && dv.DimensionValueType == 0))
                    {
                        var newItem3 = new NewCustomerCategory();
 
                        newItem3.Code = item3.Code;
                        newItem3.Name = item3.Name;
                        newItem3.ParentCode = newItem2.Code;
                        newItem3.HasChildren = false;
 
                        newItem2.HasChildren = true;
 
                        result.Add(newItem3);
                    }
 
                    result.Add(newItem2);
                }
 
                result.Add(newItem);
            }
 
            result = result.OrderBy(x => x.Code).ToList();
 
            return result;
        }
0
Aleksandar
Telerik team
answered on 23 Jun 2020, 12:08 PM

Hi Dario,

According to the provided code snippets a DropDownList is being initialized instead of a DropDownTree:

@(Html.Kendo().DropDownListFor(model=>model.NewCustomerCategoryCode)
                        .DataTextField("Name")
                        .DataValueField("Code")
                        .DataSource(dataSource => dataSource
                            .Read(read => read
                                .Action("Read_DropDownTreeNewCustomerCategoriesData", "ListBox")
                            )
                        )
                    )

Please change the widget instance to a DropDownTree and let me know if this resolves the issue.

You can also refer to the Remote Data Binding example for further details.

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Dario
Top achievements
Rank 1
Veteran
answered on 23 Jun 2020, 02:42 PM

I changed code in this way:

<div class="form-group">
    <label asp-for="NewCustomerCategoryCode" class="control-label"></label>
    @(Html.Kendo().DropDownTreeFor(model=>model.NewCustomerCategoryCode)
            .DataTextField("Name")
            .DataValueField("Code")
            .AutoWidth(true)
            .HtmlAttributes(new { style = "width: 100%" })
            .DataSource(dataSource => dataSource
                .Read(read => read
                    .Action("Read_DropDownTreeNewCustomerCategoriesData", "ListBox")
                )
            )
        )
<span asp-validation-for="NewCustomerCategoryCode" class="text-danger"></span>
</div>

But I have same effect

0
Aleksandar
Telerik team
answered on 26 Jun 2020, 10:13 AM

Hello Dario,

I reviewed the updated code and indeed the configuration looks correct. I tried to reproduce the issue but without success. Can you take a look at the attached sample project, modify it so the issue is replicated and send it back to me for further investigation?

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Dario
Top achievements
Rank 1
Veteran
answered on 01 Jul 2020, 09:41 AM

Hi Aleksandard,

I can't use your solution because I'm using Core 3.1

I would attached a solution that gives me the issue, it doesn't accept zip file.

0
Accepted
Aleksandar
Telerik team
answered on 03 Jul 2020, 01:01 PM

Hello Dario,

In general, you should be able to attach a zip file to a forum post. You might get an error if the file is too large, so I suggest removing any unnecessary data and trying again. If you still experience an issue you can upload it in a storage location of your choice.

The approach demonstrated in the sample would be applicable in an ASP.NET Core 3.1 app as well. I have made such an example as well. 

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Dario
Top achievements
Rank 1
Veteran
answered on 03 Jul 2020, 01:04 PM
Unfortunately, it doesn't accept zip format.
0
Dario
Top achievements
Rank 1
Veteran
answered on 22 Jul 2020, 09:03 AM
How can I attach zip file?
0
Aleksandar
Telerik team
answered on 27 Jul 2020, 08:29 AM

Hi Dario,

I investigated further and indeed there was a restriction for attaching zip files to this forum. It is now removed and you should be able to attach a zip file.

Regards,
Aleksandar
Progress Telerik

Tags
DropDownTree
Asked by
Dario
Top achievements
Rank 1
Veteran
Answers by
Dario
Top achievements
Rank 1
Veteran
Aleksandar
Telerik team
Share this question
or