0

I'm trying to implement a live search combo. It suppose to work like this: When I enter a character into the combo field I read the current value and send it as a parameter to the store's url. In the backend the parameter is used to return any value from the database that contains it, so the store behind the combo gets filled only with those filtered values. As I continue to enter characters into the combo, the parameter should be updated and sent again to the backend and so on, getting like this a smaller and smaller store. I tryied to achieve this behaviour using the combo's event keypress, even keyup, but the problem is it's impossible for me to get access to the current value from the combo field. For example, when I entered the "for" string into the combo, how can I obtain this value using the combo object? comboName.getValue() doesn't work, it returns nothing "".

I already saw the live combo example here: http://docs.sencha.com/extjs/4.2.2/#!/example/form/forum-search.html but doesnt help me at all.

So my big question is: how do i get the current value while still editing the combo's field?

Any help would be appreciated, thanks.

niceman
  • 161
  • 1
  • 3
  • 11

2 Answers2

0

You should be able to use

comboName.getValue();

or

comboName.getRawValue();

Where comboName is your combo box. Are neither working- I note in your post you state getValues() which is an improper method. You may want to also check whether when you're referring to your combo box object, that the reference is actually correct. The first argument from the key events is actually the object itself, so you should be able to do, e.g.

listeners:{
  keyup:function(comboBox){
      var value = comboBox.getValue() || comboBox.getRawValue();
      console.log(value);
  }
}

Swapping you the value getting method as appropriate.

SW4
  • 69,876
  • 20
  • 132
  • 137
  • Neither one works, both of them return "", while in the combo's field I already entered "re" for example. That's because the setValue method didn't fire yet. I was hoping to find a different way to get to the value. Sorry for the typo before (getValues), I updated the text. – niceman Oct 30 '13 at 15:13
  • If you assign your input field an id, have you tried just using regular js, e.g. if it has the id 'myField', using document.getElementById('myField-inputEl').value ? – SW4 Oct 31 '13 at 09:16
0

I found that the combo already has a quick search behaviour, I just have to set queryMode on 'remote' and some other small configurations. More details here: Ext Js 4.2.2 combobox queryMode

niceman
  • 161
  • 1
  • 3
  • 11