2009-08-21 2 views

답변

13

, 나는 더 빈약 예를 도울 수 생각했다.

var store = new Ext.data.JsonStore({ 
    url: '/your/ajax/script/', 
    root: 'data', // the root of the array you'll send down 
    idProperty: 'id', 
    fields: ['id','value'] 
}); 

var combo = new Ext.form.ComboBox({ 
    store: store, 
    displayField:'value', 
    typeAhead: true, 
    mode: 'remote', 
    queryParam: 'query', //contents of the field sent to server. 
    hideTrigger: true, //hide trigger so it doesn't look like a combobox. 
    selectOnFocus:true, 
    width: 250, 
    renderTo: 'autocomplete' //the id of the html element to render to. 
           //Not necessary if this is in an Ext formPanel. 
}); 

가게는 다음과 같은 형식의 서버에서 응답을 받아 들일 것입니다 : 물론

{ 
    "success": true, 
    "data": [ 
     { 
      "id": 10, 
      "value": "Automobile" 
     }, 
     { 
      "id": 24, 
      "value": "Autocomplete" 
     } 
    ] 
} 

, 즉 더 스타일의 경우도 Ext.data.XMLReader과 상점을 설정할 수 있습니다.

시작 하시길 바랍니다. 나는 Ext documentation의 awesomeness를 충분히 강조 할 수 없다. combobox samples 외에도 몇 가지 적절한 예가 있습니다. 처음에는 몇 가지 자동 완성을 만들 때 많이 사용했습니다.

+0

벌거 벗은 뼈가 도움이 되나요 :) –

+0

효과가 있습니까? – wes

+0

좋은 답변입니다. 그것은 작동합니다! – clops

6

일반적으로 입력에 일반적으로 첨부 할 수있는 별도의 자동 완성 기능이 없습니다. 서버 쪽 필터링 기능이있는 ComboBox 컨트롤을 사용하면됩니다 (hideTrigger : true 설정을 사용하여 여전히 일반 입력). 이것은 당신이 원하는 것 무엇을 아마 가장 가까운 예는 다음과 같습니다 bmoueskau가 매우 완전한 기능을 갖춘 구현을 제공하기 때문에

http://extjs.com/deploy/dev/examples/form/forum-search.html

+1

또한 로컬 필터링을 설정할 수도 있다고 생각합니다. – Thevs

+0

입력에 대해 bmoeskau에 감사드립니다. 나는 한 두 가지를 얻을 수 있는지 알아보기 위해 현상금을 올렸습니다. –

관련 문제