Unplanned
Last Updated: 09 Apr 2020 12:34 by ADMIN
Dennis
Created on: 30 Mar 2020 15:45
Category: ListBox
Type: Feature Request
2
Kendo ListBox selectedDataItems method needed

Currently, the Kendo ListBox has methods to return -- the DOM Elements using items(); the Selected DOM Elements using select(); ALL of the Data Items using .dataItems() and a SINGLE dataItem using dataItem(selector).

An additional method that would be extremely useful for this control, would be to return the SELECTED DATA ITEMS perhaps using a method  selectedDataItems().

Here is a JavaScript function that can be used as a template for providing the functionality (of course, it needs additional error checking):

    function getSelectedItems(lstName) {
         var selectedItems = [];
         //var lstItems = $(lstName).data("kendoListBox").items();
         var lstItems = $(lstName).data("kendoListBox").select();

        $(lstItems).each(function (index) {
            var selected = $(this).hasClass("k-state-selected");
            if (selected) {
                var id = "#" + $(this).attr("id");
                var dataItem = $(lstName).data("kendoListBox").dataItem(id);
                selectedItems.push(dataItem);
            }
        });
        return selectedItems;
    }

In a control such as a ListBox that inherently requires the functionality of "selection" -- then your user community would definitely need a way to not only return the selected DOM elements but also return the selected dataItems.

Hopefully, we see this functionality added to the Kendo ListBox very soon.

3 comments
ADMIN
Alex Hajigeorgieva
Posted on: 09 Apr 2020 12:34

Hi, Dennis,

Thank you very much for your feedback.

Regards,
Alex Hajigeorgieva
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.
Dennis
Posted on: 06 Apr 2020 16:25

Alex --

Thank you for your response.

If I understand your question correctly then I would go for the selected data items and not just the selectedKeyNames.

The ListBox only has 2 columns a Text and Value so returning both would (most likely) not degrade performance and then the developer would have access to both.

 

Thanks,
Dennis 

ADMIN
Alex Hajigeorgieva
Posted on: 06 Apr 2020 11:07

Hi, Dennis,

Thank you very much for the suggestion.

The Kendo UI ListBox would indeed benefit from such a method due to the nature of its purpose. For comparison, the grid has a select() method and also a selectedKeyNames() method which returns an array of the ids of all selected items. Would that be better or would you like to see the entire dataItem instead?

The more popularity this item gains, the quicker we will be able to push it forward to the attention of the Product Management team.

Kind Regards,
Alex Hajigeorgieva
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.