0

データベース内のカスタム テーブルからいくつかのフィールドを表示する EXTjs グリッドがあります。

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

         }

私のタイプ テーブルには typeid と name があります。私のグリッドには番号が表示されます。代わりに、その 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: 'name' を使用すると、ID の代わりにコンボ表示名が作成されます。グリッドで同じことを行うにはどうすればよいですか?

4

1 に答える 1

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;
}
于 2014-03-20T05:35:02.483 に答える