2016-06-27 5 views
0

私のPentaho CDEダッシュボードにテーブルコンポーネントがあり、データソースはSQLです。私は、行のこの表の名前と列ヘッダーの上に行として列を追加する必要があり、このcdeテーブルコンポーネントに行名を追加

enter image description here

のような表を作りたいです。 ここにメソッドがあります: Table Component SubColumns ヘッダーを追加するにはどうすればいいですか?

答えて

0

余分な列の部分を行う巧妙な方法は、クエリ結果オブジェクトをクエリから取得した後に変更して、必要に応じて列と行を追加することだと思います。あなたは、最初の引数としてクエリ結果オブジェクト取りPostFetchコールバック関数、でこれを行うことができます。

function yourTableComponentPostFetch(queryResult) { 
    // Let's say you have an array of row names 
    var rowNames = ['Title1', 'Title2', ... ]; 

    // Add a "title" column for every row 
    queryResult.resultset.forEach(function (row, idx) { 
     // Push it at the beginning of the row array 
     row.unshift(rowNames[idx]); 
    }); 

    // Change metadata description of columns to reflect this new structure 
    queryResult.metadata.unshift({ 
     colName: 'Title', 
     colIndex: -1, // this makes sense when reindexing columns below ;) 
     colType: 'String' 
    }); 

    // One last re-indexing of metadata column descriptions 
    queryResult.metadata.forEach(function (column, idx) { 
     // The title added column will be 0, and the rest will rearrange 
     column.colIndex++; 
    }); 
} 

だけトリッキーな部分は、あなたが効果的にデータセットの構造を変更しているので、メタデータの変更についての部分であり、およびqueryResultオブジェクトがその参照を変更するのではなく、インプレースで更新されていることを確認します(queryResult = myNewQueryResultは機能しません)。しかし、私が提案したコードはそのトリックを行うべきです。

関連する問題