kendo-ui grid custom editor multiselect set value

1.8k views Asked by At

I'm trying to set the values for an multiselect editor, as in:

http://dojo.telerik.com/oneGE

But when I implement same in a Kendoui Grid custom editor the value setting is ignored.

The editor is setup in the grid declaration as a function:

$("#rocongrid").kendoGrid({<br/>
    ....
    editor : function (container,options) {
        $('<select multiple="multiple"  data-bind="value:' + options.field + '"/>')
            .appendTo(container).kendoMultiSelect({
                dataTextField: "genre",
                dataValueField: "genre",
                dataSource: GenreDS,
                value: [ "Classical" ]
            });
        }
    },

The "Classical" item is set fine in the dojo sample, but in the Grid Edit mode it does not. Is there something I am not implementing in the custom editor?

1

There are 1 answers

2
OnaBai On BEST ANSWER

There are a couple of questions that you need to consider when implementing multiselect in a Grid.

  1. Values are not going to be a single value but an array of values so you need to implement some way for displaying it as (for example) comma separated values.
  2. if you use data-bind="value:' + options.field + '" then this will overwrite value: [ "Classical" ]. Actually the later does not make sense since what you want is initially showing the values that are already stored in the Grid DataSource