How to limit Combo cell in grid to Options but allow Filterg

I want to set the enableFilteringMode(true) in a combo inside a grid but I want to only allow that the user chooses from available options ONLY. Currently they can also type anything else inside the box and tab out which breaks my code later. What is the best method of doing this please?


There is not ready solution do that. However, you may try to test typed text manually on keypress event:

var text = ""; var combo = grid.getColumnCombo(columnIndex); combo.enableFilteringMode(true); var options = [[1,"one"],[2,"two"],[3,"three"]]; combo.addOption(options); combo.attachEvent("onKeyPressed",function(code){ if(checkText(this.getComboText())) text=this.getComboText(); else this.setComboValue(text); })

Here checkText is your function that tests the typed value. For example:

function checkText(value){ for(var i=0; i<options.length; i++){ if(options[i][1].toString().toUpperCase().indexOf(value.toUpperCase()) == 0) return true; } return false; }

Sorry Alexandra this does not work for me because I load all my combos through XML url. Is there any way to iterate through the list of options in a combo? I would be happy with a solution which allowed me to test whether the entered value matched a combo ‘label’ or not after the edit had been finished.

How does getOptionByLabel work? I tried using it but couldn’t work out what it was returning. It either returned null or [object Object]. What does that mean?

Given the normally EXCELLENT functionality of your software, I am somewhat surprised by the lack of this basic functionality in a Combo box.

Any further help you can give would be very WELCOME because some of my combos have 300+ options and for that you definitely need Filtering.


Combo options are stored in the optionsArr private array:

for(var i=0; i<combo.optionsArr.length; i++){ var text = combo.optionsArr[i].text; /*your code here*/ }