Hello,I am having issues trying to set the selected items in the multiSelection combo box.I have an array propery bound to the 'Products' column in the grid. when the edit dialog opens, the multiSelection combo box checks the item if there is only one in the array, but if there are many, no items are being selected.
How can i select all items from the bound array column when the edit dialog opens?
The example attached as two records that have multiple products assign and would like to see these items to be checked and selected in the multisection combobox.
igGrid_uploadControl.zip
Hello BenIn the grid configuration of the sample previously attached I noticed that the mode option of the combo editor is set to “dropdown”. When this mode it used, only values from the drop down list can be selected. This is the reason why the first item is always selected (if there is no match with the combo data source) and there is no “select..” text in the input area.When you need a placeholder where you can type the options, “editable” mode can be used. This mode will allow you to modify value by edit field and drop down list. It also can be configured to not allow custom valuesHere is an example on how to set the editor:
editorOptions: { mode: "editable", allowCustomValues: false, width: "340px", dataSource: list }
2477.igGrid_uploadControl.zip
Thank you Martin.
I am using version 17.1
This makes sense. If the cell value exists in the dataSource, that items should be selected.
When clicking the "add new row", I would expect the 'Prod List' combo to not have a value selected and show the placeholder value instead, as there is not a value for a new Row. This does not happen and the first item from the dataSource is selected. How can I have the 'add new row' not select the first item in the dataSource and require an item to be selected?
Hello Ben,By design the initially selected value of the igCombo editor provider is the cell value if it is available in the combo`s dataSource.
Attached you can find a sample that has initially selected items in combo editor provider.
If the igCombo is used as separate control rather than an editor provider the placeholder option that is part of the Combo’s locale options can be used. It sets value that is displayed when input field is empty. However, when used in igGrid the value for the placeholder is the cell value.
Feel free to ask any additional questions.
4571.combo_initial_sample.zip
Thank you for the direction.I also wanted to know if there is a way to show a placeHolder or the "select..." option for an igCombo that is single selection or multiSelection.enabled:false?it seems when i use a single selection, the first option in the igCombo is always defaulted. I want to force a selection for the single select igCombo
Hello Ben,
I updated the sample you previously sent that supports multiple selection in igCombo.
By design grid doesn’t allow saving complex values in the data source such as arrays. This means that custom implementation should be applied if multiple selection is needed.
This can be done by creating a custom editor provider that extends the default EditorProviderCombo and overwrite its default getValue and setValue methods. Here is an example on how to set the custom provider:
$.ig.ComboEditorProviderCustom = $.ig.EditorProviderCombo.extend({ getValue: function () { var val = this.editor.value(); var text= this.editor.text(); if ($.type(val) === "array" && val.length) { //When the passed value is of complex type return the text instead. //This will be the value saved in the grid data source after editing ends. return text; } return val; }, setValue: function (val, fire) { var array = []; this.editor.deselectAll(); if (this.options.multiSelection.enabled && val.contains(this.options.multiSelection.itemSeparator)) { //if multiSelection is enabled and the value passed from the grid cell to the edito contains the specified itemSeparator //Then split the value by the separator and set a complex value back to the editor so that the matching items will get selected. array = val.split(this.options.multiSelection.itemSeparator); return this.editor.value(array, null, fire); } this.editor.value(val, null, fire); } });
You can see more information about this here.
Feel free to ask me any additional questions.
igGrid_uploadControl_updated.zip