kendo-labs / knockout-kendo

A project to create a robust set of Knockout.js bindings for the Kendo UI widgets.
http://kendo-labs.github.com/knockout-kendo/
273 stars 144 forks source link

Multiselect with serverFiltering not working properly #177

Open NiSHoW opened 9 years ago

NiSHoW commented 9 years ago

Hello, I'd like to report a possible bug concerning the integration of the multiselect component with knockout. See the fiddle below and steps to reproduce. Thanks

http://jsfiddle.net/n2r69t3a/2/

This field shows the working of the multi select with server filtering of a standard kendo component compared to a knockout integrated one. To reproduce:

    Kendo's standard multiselects works as expected but the integrated one, in visualization, clears
    the previous entries and leaves the last and longest.
    If you then select yet a new one, the observable will be reset.
pkmccaffrey commented 7 years ago

I ran into this problem today. With "serverFiltering" set to true, only the most recently selected value exists in the "value" array, and the input in the UI is empty.

I debugged through it, and the problem is in the value property's "watch" function (around line 862 of the non-minified source):

   createBinding({
        name: "kendoMultiSelect",
        events: {
            change: VALUE,
            open: {
                writeTo: ISOPEN,
                value: true
            },
            close: {
                writeTo: ISOPEN,
                value: false
            }
        },
        watch: {
            enabled: ENABLE,
            search: [SEARCH, CLOSE],
            data: function (value) {
                ko.kendo.setDataSource(this, value);
            },
            value: function (value) {

                //NOTE:  This breaks server filtering, for some reason...
                //After selecting a value, the input is blank, and the values array only contains the most recently selected value

                //this.dataSource.filter({});
                //this.value(value);

            }
        }
    });

The above snippet has the problem code commented out, and as far as I can tell, things seem to work without. That code appears to attempt to reset the Kendo filter, and then set's the value observable to the new value (is this necessary? isn't the observable already up to date at this point?).