How to prevent Kendo MultiSelect from losing values ​​after editing in a grid template?

I have a grid that displays a list of values ​​separated by commas, and has an array that is used in the template editor for the grid. (On the server, I will convert the comma-separated list to an array for the Kendo AngularJS multi-element command). Almost everything works for me: displaying, editing and adding values ​​to multiselect.

There is only one strange thing: after I add the value to the multi-selection, click “Save” in the editor and open the editor again, and the multi-selection will display only one of the last values. I know that values ​​exist and pass through the pipeline because the values ​​contribute it to the database. I can refresh the page, open the editor and all the values ​​displayed in multimode order, including the one I just added.

As if kendo "forgets" most of the values ​​when you reopen the editor. How can this be prevented? Does MultiSelect need to be disabled for values? If so, how?

I tried to add this onChange event , but this did not affect. I added valuePrimitive with no effect. I tried to specify k-rebind, but this caused an error.

Here the directive is used in text/x-kendo-template:

        <select kendo-multi-select
                id="zipCode"
                k-placeholder="'Enter zip codes...'"
                style="width: 225px"
                k-on-change="dataItem.dirty=true"
                k-auto-bind="false"
                k-min-length="3"
                k-enforce-min-length="true"
                k-data-source="options.zipCodeDataSource"
                k-data-text-field="'text'"
                k-filter="'startsWith'"
                k-filtering="options.zipCodeFiltering"
                k-no-data-template="'...'"
                k-ng-model="dataItem.zipArray"
                k-highlight-first="true" />

And this is a DataSource:

options.zipCodeDataSource = new kendo.data.DataSource({
    severFiltering: true,
    transport: {
        read: {
            url: serviceUrl + "ZipCode/Get",
            type: "GET",
            dataType: "json",
            contentType: jsonType,
            data: function (e) {
                // get your widget.
                let widget = $('#zipCode').data('kendoMultiSelect');
                // get the text input
                let filter = widget.input.val();
                // what you return here will be in the query string
                return {
                    filter: filter
                };
            }
        },
    },
    schema: {
        data: "data",
        total: "Count",
        model:
        {
            id: "text",
            fields: {
                text: { editable: false, defaultValue: 0 },
            }
        },
        parse: function (response) {
            return response;
        }
    },
    error: function (e) {
    }
});

If I show {{dataItem.zipArray}}in <pre>, all expected values ​​are there.

I wonder if something needs to be added to the editing event handler in the kendo grid definition, but I'm not sure what it will be. I needed to make a binding for the dropdownlist directive.

    edit: function (e) {

        if (e.model.marketId === 0) {
            e.container.kendoWindow("title", "Add");
        } else {
            e.container.kendoWindow("title", "Edit");
        }

        // re-bind multi-select here??

        // These two lines actually cause the multiselect to lose pre-existing items in dataItem.zipArray
        // var multiselect = kendo.widgetInstance(angular.element('#zipCode'));
        // multiselect.trigger('change');
    }

...

Update:

This dojo demonstrates the problem .

  • Run dojo
  • Edit the first entry in the Contracts grid
  • Add a zip code, e.g. 22250
  • Click "Save."
  • Then click "Edit" on the first line again
  • 22250

, , k-min-length="3" k-min-length="1", . , , 3.

+4
1

, , . here.

Ok, telerik, ​​ R3 SP1 2017 (2017.3.1018). , dojo:

http://dojo.telerik.com/IREVAXar/3

+3

Source: https://habr.com/ru/post/1694877/


All Articles