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

Grouping when binding to Local Data

3 Answers 497 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 30 Apr 2015, 01:41 PM

 

Is it possible to using the new grouping when binding to local data?

 My current code is:

.DataSource(ds => ds
    .Custom()
    .Group(g => g.Add("ParentTaskName", typeof(string)))
    .Transport(transport => transport
        .Read(read =>
        {
            read.Action("TaskEditor_Read", "TimeEntry").Data("GetClosestTicketId()");
        })))

I, however, don't want to use a datasource, I want to bind my dropdown to local data using .BindTo(.....) but still group by the ParentTaskName.

Is this possible?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 04 May 2015, 08:15 AM
Hello Robert,

The group option can be defined only though the DataSource fluent method. Hence you will not be able to combine remote (DataSource) with local (BindTo) data binding. 

Regards,
Georgi Krustev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Diego
Top achievements
Rank 1
answered on 03 Nov 2017, 04:25 PM
Is it still impossible to group a dropdown/combo when using local data such as when binding through BindTo?
0
Ivan Danchev
Telerik team
answered on 07 Nov 2017, 12:16 PM
Hello Diego,

Grouping is a functionality of the Kendo UI DataSource. When the widget is bound to local data with the BindTo method DataSource is not configured, so to group the data in such scenarios you would need to use the API (the dataSource's group method), for example:
<div id="container"
    @(Html.Kendo().DropDownList()
            .Name("cars")
            .DataTextField("Text")
            .DataValueField("Value")
            .OptionLabel("Select...")
            .Filter("contains")
            .BindTo(new List<SelectListItem>() {
                new SelectListItem() {
                    Text = "370Z",
                    Value = "Nissan"
                },
                new SelectListItem() {
                    Text = "GT-R",
                    Value = "Nissan"
                },
                new SelectListItem() {
                    Text = "Corolla",
                    Value = "Toyota"
                },
                new SelectListItem() {
                    Text = "Camry",
                    Value = "Toyota"
                },
                new SelectListItem() {
                    Text = "GT-86",
                    Value = "Toyota"
                }
            })
            .HtmlAttributes(new { style = "width: 100%" })
    )
</div>  
<script>
    $(document).ready(function () {
        var ddl = $("#cars").data("kendoDropDownList");
        ddl.dataSource.group({ field: "Value" });
        var view = ddl.dataSource.view();
    })
</script>




Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DropDownList
Asked by
Robert
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Diego
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or