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

kendo combobox & kendo-knockout dynamic add/remove next available value set

3 Answers 229 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Navnit
Top achievements
Rank 1
Navnit asked on 04 Jun 2012, 07:23 PM
The issue happens when I try to set the next available value in combobox, here is what my scenario is.

I have a list of available items which I display in a combobox, user can select one item & assign at which point I add it to a list/table, user can remove an item from selected at which point it goes back into available list.

Now the issue occurs when the following is done
 1) Select & assign couple of items (notice next available item is selected in combobox)
 2) Remove an item from the selected list/table (item should now be available to select in combobox)
 3) Now try to select the same item & Assign again & notice the next available value in combobox.

Here is a jsFiddle where issue can be reproduced (works only on chrome) http://jsfiddle.net/navnitmehta/fHXBx/7/

I am not sure if this is an issue with kendo or kendo-knockout binding.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Navnit
Top achievements
Rank 1
answered on 30 Aug 2012, 04:32 PM
It turns out that this might potentially be a bug with Kendo, mainly Kendo filter value is persisted until the next time user uses kendo combo, so if we try to set a value pragmatically; kendo thinks that the value does not exist & sets the Value as text details can be found here https://github.com/rniemeyer/knockout-kendo/issues/12
0
Georgi Krustev
Telerik team
answered on 31 Aug 2012, 01:04 PM
Hi Navnit,

 
After the item is assigned (if the combobox is filtered and only one item has left), the refresh method of the widget is called, but the applied filter is not removed. You will need to do it manually as the refresh method is not intended to do it. Here is the modified method:

this.assignItem = function () {
                        debugger;
                        var selecteditem = self.allItems.remove(function (item) {
                            return item.Key() == parseInt(self.selectedItem());
                        });
                        self.assignedItems.push(selecteditem[0]);
 
                        if (self.allItems().length > 0) {
                            self.selectedItem(self.allItems()[0].Key());
                        } else {
                            self.selectedItem(""); /* If not more items available in dropdown */
                        }
                        $("#allitems").data("kendoComboBox").dataSource.query({});
                    };


Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Navnit
Top achievements
Rank 1
answered on 31 Aug 2012, 08:23 PM
Since we are using Kendo with Knockout-kendo bindings, we wanted a generic implementation where we don't need to implement this all over the place, so right now we do the following in tie change event of combobox, its working nice so far without any side effects.

this.dataSource.filter({});
Tags
ComboBox
Asked by
Navnit
Top achievements
Rank 1
Answers by
Navnit
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or