2013-07-04 1 views
0

나는 데이터베이스에 내 손님 테이블에서 일부 필드를 표시하는의 ExtJS 그리드 .. 다음의 ExtJS 3.4.0 NAME과 그리드의 ID 필드를 렌더링

Reports.grid.Reports = function(config) { 
    config = config || {}; 
    Ext.applyIf(config,{ 
     id: 'reports-grid-reports' 
     ,url: Reports.config.connectorUrl 
     ,baseParams: { action: 'mgr/reports/getList' } 
     ,save_action: 'mgr/reports/updateFromGrid' 
     ,fields: ['id','name','filename','remark','year','resourceID','typeID','visible'] 

하고 있습니다

{ 
      header: 'Type ID' 
      ,dataIndex: 'typeID' 
      ,sortable: true 
      ,width: 100 

     } 

을 내 타입 테이블은 타입 ID와 이름을 가지고 있습니다. 그리드에 숫자가 표시됩니다. 대신 테이블에 ID에 해당하는 이름을 표시하도록 말할 수 있습니까?

Reports.combo.Types = function(config) { 
    config = config || {}; 
    Ext.applyIf(config,{   
     name: 'typeID'  
     ,hiddenName: 'typeID' 
     ,displayField: 'name' 
     ,valueField: 'id' 
     ,fields: ['name','id'] 
     ,listWidth: 380  
     ,pageSize: 20 
     ,url: Reports.config.connectorUrl 
     ,baseParams: { 
       action: 'mgr/reports/gettypelist2', 'combo': true 
      }   
    }); 
    Reports.combo.Types.superclass.constructor.call(this,config); 
}; 
Ext.extend(Reports.combo.Types,MODx.combo.ComboBox); 
Ext.reg('combo-modx-types',Reports.combo.Types); 

, displayField를 사용 :

는 나는 또한 업데이트 창에 사용하는 콤보를 얻었다 '이름'대신 내가 그리드에서 같은 일을 할 수있는 방법 아이디 ..의 콤보 표시 이름을 무엇입니까?

답변

0

질문을 올바르게 이해하면 ExtJS보다는 getList 프로세서를 직접 사용자 정의해야한다고 생각합니다. afterIteration() 함수를 재정의하십시오. 의 라인을 따라 뭔가 : 어쩌면

public function afterIteration(array $list) { 
    $rows = array(); 
    foreach ($list as $row){ 
     // This calls a custom getName() function that gets the name from the other table 
     $row['typeID'] = $this->getName($row['id']); 
     $rows[] = $row; 
    } 
    return $rows; 
} 

하고 getName() 함수는 할 수있는 일 같은 :

private function getName($id) { 
    $otherTable = $this->modx->getObject('TABLE_ALIAS_HERE', array('internalKey' => $id)); 
    $name = $otherTable->get('name'); 
    return $name; 
}