ExtJs-用户开始输入新值时如何清除可编辑组合框中的现有值

问题描述 投票:1回答:1

我有一个可编辑的组合框。默认情况下,此组合框中将存在一个现有值,或者用户从下拉列表中选择它。现在,如果用户想在此组合框中输入新值,我希望在用户第一次按键时清除现有值。现在,我必须手动选择现有值并将其删除,然后开始输入新值。有没有一种方法可以解决此问题,因此,一旦用户开始在组合框中键入一个值,就应该清除旧值。

谢谢,

extjs combobox type-ahead
1个回答
2
投票
 1. You can do it by using **focus** event listener for combo
 listeners:{
    focus:function( combo, The, eOpts ){
             combo.clearValue();
           }

  }
 2. You can use **keypress/keyup** event listeners also depending

根据您的要求,使用enableKeyEvents:true组合键启用按键事件。

 listeners:{
    keypress:function( combo, e, eOpts ){
             combo.clearValue();
           }

  }
© www.soinside.com 2019 - 2024. All rights reserved.