2010-07-30 5 views
2

ComboBox의 선택된 값에 템플릿을 적용 할 수있는 방법이 있습니까? 템플릿을 사용하여 ComboBox의 드롭 다운 값을 표시하지만 데이터를 선택하면 바로 데이터 저장소의 일반 값이 표시됩니다.Ext.form.ComboBox : displayField의 템플릿 사용

{ 
    id:    'requestStatusCombo', 
    hiddenName:  'requestStatus', 
    tpl:    '<tpl for="."><div class="x-combo-list-item">{statusCode:requestStatus}</div></tpl>', 
    fieldLabel:  'Status', 
    xtype:    'combo', 
    mode:   'local', 
    triggerAction:  'all', 
    store:    new Ext.data.ArrayStore({ 
     fields:  ['statusCode'], 
     data:  [['unassigned'],['assigned'],['closed']] 
    }), 
    valueField:  'statusCode', 
    displayField: 'statusCode' 
} 

나는 로케일 spesific 상태 이름으로 statusCodes 번역 내 포맷 기능 requestStatus를 사용하려면,이 드롭 다운 목록을 위해 잘 작동하지만 곧 뭔가를 선택 같이 statusCode가 표시됩니다.

템플릿을 displayField에 할당하거나 데이터 저장소에서 간단한 일괄 수정을 수행 할 수 있습니까? 어쩌면 독자를 통해 입력을 처리함으로써? 이 문제를 일으킬 다른 <tpl for="?"> 키워드가 있습니까?

저는 Ext 라이브러리를 사용하는 간단한 방법을 찾고 있습니다. 유일한 해결책이 데이터를 사전 처리하는 것이라면, 나는 그것을 스스로 할 수 있습니다.

답변

3

나는 해결책을 발견!

나는 내 데이터 저장소를 변경하고, 변환 기능을 사용하여 상태를 프로세스를 사전에 독자를 추가 :

{ 
    id:    'requestStatusCombo', 
    hiddenName:  'requestStatus', 
    fieldLabel:  'Status', 
    xtype:    'combo', 
    mode:   'local', 
    triggerAction:  'all', 
    store:    new Ext.data.Store({ 
     data:  [['unassigned'],['assigned'],['closed']], 
     reader:  new Ext.data.ArrayReader({},[ 
      {name: 'statusCode', mapping: 0}, 
      {name: 'displayname', mapping: 0, convert: function(statusCode) { 
       return Ext.util.Format.requestStatus(statusCode); 
      }} 
     ]) 
    }), 
    valueField:  'statusCode', 
    displayField: 'displayname' 
} 
2

DOM을 생성하면 목록 요소가 DIV이지만 필드 자체는 html INPUT 요소라는 것을 알 수 있습니다. INPUT 요소 안에 HTML을 넣을 수는 없습니다 ... 그래서 xtemplate는 없습니다.

이는 Ext.form.ComboBox (또는 어쩌면 Ext.Component의)를 확장하여 할 수없는 것을 의미하지 않는다

관련 문제