2017-10-27 1 views
0

다음과 같은 콤보가 있습니다.콤보 선택 불가 첫 번째 값

Ext.create('Ext.form.ComboBox', { 
      fieldLabel: 'Label', 
      allowBlank: true, 
      maxLength: 50, 
      minChars: 10000, 
      name: 'txt', 
      id: 'txt', 
      store: states, 
      displayField: 'name', 
      selectOnFocus: false, 
      forceSelection: false, 
      typeAhead: false, 
      autoSelect: false, 
      queryMode: 'local', 
      triggerAction: 'all', 
      hideTrigger: true, 
      listeners: { 
       beforequery: function (record) { 
        record.query = new RegExp(record.query, 'i'); 
        record.forceAll = false; 
       }, 
       specialkey: function (f, e) { 
        if (e.getKey() == e.ENTER) { 
         doProcess(); 
        } 
       } 
      }, 
      renderTo: Ext.getBody() 
     }); 

내 목적은 기록을 저장하는 텍스트 상자를 작성하는 것입니다. 나는이 해결책을 찾았다. 텍스트 필드와 같은 콤보를 사용해야한다. 지금까지 문제가 없습니다. 하지만 뭔가를 쓰고 전에 검색 한 목록에서 레코드를 선택하면 다음 번에 콤보가 쓰는 동안 자동으로 선택합니다. 내가 설명했는지 잘 모르겠다.

당신은 여기를 테스트 할 수 https://fiddle.sencha.com/#view/editor&fiddle/28tl

감사합니다.

+1

의미 선택기에서 마지막으로 선택한 항목의 선택을 취소 하시겠습니까? –

+0

정확히 원하는 것. 귀하의 정보에서 이해할 수 없습니다. – Tejas

+0

맞아, 내가 다른 것을 쓸 때 콤보 아이템을 선택 해제하고 싶다. –

답변

0

안녕하세요. 다음과 같은 문제를 해결했습니다.

https://fiddle.sencha.com/#view/editor&fiddle/28tl

이 예제는 내 질문보다는 좀 더 명확 알려줍니다.

Ext.application({ 
    name: 'Fiddle', 

    launch: function() { 
     // The data store containing the list of states 
     var states = Ext.create('Ext.data.Store', { 
      fields: ['abbr', 'name'], 
      data: [{ 
       "abbr": "AL", 
       "name": "Alabama" 
      }, { 
       "abbr": "AK", 
       "name": "Alaska" 
      }, { 
       "abbr": "AZ", 
       "name": "Arizona" 
      }] 
     }); 

     // Create the combo box, attached to the states data store 
     Ext.create('Ext.form.ComboBox', { 
      fieldLabel: 'Label', 
      allowBlank: true, 
      maxLength: 50, 
      minChars: 10000, 
      name: 'txt', 
      id: 'txt', 
      store: states, 
      displayField: 'name', 
      selectOnFocus: false, 
      forceSelection: false, 
      typeAhead: false, 
      autoSelect: false, 
      queryMode: 'local', 
      triggerAction: 'all', 
      hideTrigger: true, 
      enableKeyEvents: true 

      , 
      listConfig: { 
       listeners: { 
        itemclick: function (list, record) { 
         _iseFareIleSecildi = true; 
        }, 
        highlightitem: function (view, node, eOpts) { 
         _iseKlavyeIleSecildi = true; 
        } 
       } 
      }, 
      listeners: { 
       beforequery: function (record) { 
        record.query = new RegExp(record.query, 'i'); 
        record.forceAll = false; 
        Ext.defer(function() { 
         secimiSifirla(); 
        }, 30); 
       }, 
       specialkey: function (f, e) { 
        if (e.getKey() == e.ENTER) { 
         console.log('action'); 
        } 
       }, 
       keyup: function (combo, e) { 
        if (e.getKey() == e.ENTER) { 
         console.log('action'); 
        } 
       }, 
       beforeselect: function (combo, record, index, eOpts) { 
        if (_iseFareIleSecildi) { 
         secimiSifirla(); 
         return true; 
        } else { 
         if (_iseKlavyeIleSecildi) { 
          secimiSifirla(); 
          return true; 
         } else { 
          return false; 
         } 
        } 
       } 
      }, 
      renderTo: Ext.getBody() 
     }); 
    } 

}); 

var _iseFareIleSecildi = false; 
var _iseKlavyeIleSecildi = false; 

function secimiSifirla() { 
    _iseFareIleSecildi = false; 
    _iseKlavyeIleSecildi = false; 
} 

감사합니다.

0

은 당신과 같이 falsetrackOver boundlist의 설정을 설정할 수 있습니다

xtype: 'combo', 
... 
listConfig: { 
    trackOver: false 
} 

바이올린 : https://fiddle.sencha.com/#view/editor&fiddle/2945

+0

안녕하세요. 설명 할 수 없었습니다. 예를 들어 ALABAM-> ALABA-> ALAB과 같이 "Alabama"를 선택한 다음 백 스페이스를 입력하면 "ALABAMA"가 자동으로 선택됩니다. 하지만이 동작은 원하지 않습니다. 콤보는 항목을 필터링 만하고 선택하지 않아야합니다. 어떻게해야합니까? 바이올린 샘플을 시도하면 이전 선택으로 자동 완료되지 않을 수 없습니다. 죄송합니다 내 영어. 감사합니다. –

0

는 "tagfield"로 시도합니다. Check here

+0

고마워,하지만 내가 필요한 것과 똑같은 행동을하지는 못했다. 이것은 검색 상자이며 스타일에 태그를 지정하고 싶지 않습니다. 그리고 나는 기대했던대로 행동하지 않습니다. 감사합니다. –

관련 문제