5

How to select combo value on click of enter.

I am using combobox and values are coming by using mouse click and click on enter. But When I choose second value by click on enter 1st value is disappear. I a using keyboard and value appear in search. How to resolve this.

In my fiddler please select two value by click on enter, first value is disappear by clicking the second one.

Please help me to fix this. MyFiddler.

Note : I don't want to use tagfield.

David
  • 4,266
  • 8
  • 34
  • 69
  • I think page is being reloaded after `button` click.. – Rayon Sep 26 '16 at 06:51
  • The select is working on click and selected text so when you are hovering some item it is selected and on click it is getting added but when you are hovering and entering something it is entered in combox box and on selecting other the hover for the first item is remain entact so on entering it is getting deseselct – Tanmay Sep 26 '16 at 06:55
  • Your question is not quiet clear to me. I think there is nothing wrong with your code. I can select multiple values by both pressing ENTER and clicking on the value. – Han Sep 26 '16 at 06:55
  • @Tanmay what is the solution of this. – David Sep 26 '16 at 06:58
  • @Han I can not select multiple value by enter. Once you use 2nd value first value disappear from box – David Sep 26 '16 at 06:58
  • It's weird but I can. First you select the first value by clicking MOUSE, then you press the DOWN arrow twice, because for the first time, it moves to your selected value (if you press ENTER now, it will deselect your value). – Han Sep 26 '16 at 07:01
  • You can go for one of the options, make user add an item on mouse click only or make it on enters only that what it seems to be, otherwise wait for answers – Tanmay Sep 26 '16 at 07:02
  • 1
    @Han Exactly in that way it is working, But like I am searching value and then press entering instead of moving arrows from keyboard. – David Sep 26 '16 at 07:04
  • @Tanmay Actually I am searching option from field so in that can can not use this option. – David Sep 26 '16 at 07:04

1 Answers1

1

The Combobox control is deliberately built around having only one selection. It used to support multi-select, but that's been deprecated since Ext 5.1 and will presumably vanish or break in nasty ways.

The only built-in way to do what you want is with Tag Fields (which you've indicated you don't want), or the Ext.view.MultiSelector class. The latter isn't a single field, but a variant of a grid.

Robert Watkins
  • 2,196
  • 15
  • 17
  • Thanks, This I know can you check in lower version of Ext and see weather my requirement is working there or not. – David Sep 26 '16 at 11:35
  • Well, your question is tagged 'extjs6', so I'm assuming you're using that. Your fiddle is for ExtJS 6.2. That's what I answered. But I looked at your Fiddle in ExtJS 5.0.1 as well, and it still doesn't work the way you want. I suspect that this is part of why the multiSelect option is deprecated – Robert Watkins Sep 26 '16 at 11:43
  • The problem is that the 'type-to-search' feature is clashing with how the mutliSelect value is stored. Because the combobox only has one value, the multiSelect feature uses a hack of storing the values separated by semi-colons. But the type-to-search doesn't work with that, so it erases the other values. This is by design, and is unlikely to be worked around, except by disabling the 'type-to-search' feature all together. – Robert Watkins Sep 26 '16 at 11:44
  • Thanks. I will change to `tagfield`. I guess that is better. – David Sep 26 '16 at 12:15