2011-03-17 2 views
3

Ext.Window를 통해 표시하는 EditorGridPanel이 있습니다.ComboBox는 클릭했을 때 displayField 만 표시합니다.

resources은 Ajax 호출을 통해 얻은 Json 데이터입니다.

예 데이터 : {"data":[{"id":"1","allowed":"1","roleId":"0","resource":"nothing"}]}

문제는 내가 콤보 상자를 클릭하면 콤보 상자의 displayField 만 표시된다는 점이다. 클릭하면 "허용됨", "허용되지 않음"을 선택할 수 있습니다. 포커스를 제거하면 값이 표시됩니다 : "1", "0".

클릭하지 않은 경우에도 displayField 값을 표시하려면 어떻게해야합니까?

showRoleDetails: function(resources, roleId) { 
     var rolesData = resources; 

     var store = new Ext.data.JsonStore({ 
      url: '/plugin/Registration/admin/get-acl-resources-of-role', 
      baseParams: { role: roleId}, 
      storeId: 'myStore', 
      root: 'data', 

      fields: [ 
         {name: 'allowed'}, 
         {name: 'resource'} 
         ] 
      }); 

     store.load(); 

     var grid = new Ext.grid.EditorGridPanel({ 
      title: "Edit/View permissions for resources", 
      store: store, 
      autoHeight: true, 
      columns: [ 

         { 
          header: 'Allowed', 
          dataIndex: 'allowed', 
          editor: new Ext.form.ComboBox({ 
           triggerAction: 'all', 
           frame: true, 
           lazyRender:true, 
           editable: false, 
           mode: 'local', 
           value: 'allowed', 
           store: new Ext.data.JsonStore({ 
             fields : ['allowed', 'allowedLabel'], 
             data : 
              [ 
               { 
                allowed: '1', 
                allowedLabel: 'allowed' 
               }, 
               { 
                allowed: '0', 
                allowedLabel: 'not allowed' 
               } 
              ] 
           }), 
           valueField: 'allowed', 
           displayField: 'allowedLabel' 
          }) 
         }, 
         { 
          header: 'Resource', 
          dataIndex: 'resource' 
         } 
         ] 
     }); 

     var window = new Ext.Window({ 
      items: grid 
     }); 
     window.show(); 

    } 

편집 :Following 나렌드라 업에의 반응은, 나는 같은 내 코드 편집 :이 멋지고 작동

var comboBox = new Ext.form.ComboBox({ //Combox values need to be filled up 
     triggerAction: 'all', 
     frame: true, 
     lazyRender:true, 
     editable: false, 
     mode: 'local', 
     value: 'allowed', 
     store: new Ext.data.JsonStore({ 
       fields : ['allowed', 'allowedLabel'], 
       data : 
        [ 
         { 
          allowed: '1', 
          allowedLabel: 'allowed' 
         }, 
         { 
          allowed: '0', 
          allowedLabel: 'not allowed' 
         } 
        ] 
     }), 
     valueField: 'allowed', 
     displayField: 'allowedLabel' 
    }) ; 

    var me = this; 

    var grid = new Ext.grid.EditorGridPanel({ 
     title: "Edit/View permissions for resources", 
     store: store, 
     autoHeight: true, 
     columns: [ 

        { 
         header: 'Allowed', 
         dataIndex: 'allowed', 
         editor: comboBox, 
         renderer: me.comboBoxRenderer(comboBox) 
        }, 
        { 
         header: 'Resource', 
         dataIndex: 'resource' 
        } 
        ] 
    }); 

.

답변

4

직접 표시 값을 렌더링해야합니다. 그리드 열 사양에서 렌더러 옵션을 찾으십시오.

  1. 구성 렌더러
  2. 그 것이다 (값이 문자 그대로 받아 들인다) 당신이 당신의 논리에 표시 값에 내놓고을 반환 할 수 있습니다 선택된 값 및 관련 매장 기록
  3. 를 제공
관련 문제