Grouping when binding to Local Data

4 posts, 0 answers
  1. Robert
    Robert avatar
    18 posts
    Member since:
    Feb 2014

    Posted 30 Apr 2015 Link to this post

     

    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?

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3725 posts

    Posted 04 May 2015 Link to this post

    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.

     
  3. Diego
    Diego avatar
    6 posts
    Member since:
    Aug 2016

    Posted 03 Nov in reply to Georgi Krustev Link to this post

    Is it still impossible to group a dropdown/combo when using local data such as when binding through BindTo?
  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1301 posts

    Posted 07 Nov Link to this post

    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.
Back to Top