0

私はJavaScriptループを使用して、図で構成されたテーブルを作成しています。コードは現在、テーブルを正常に作成しており、いくつかのスタイルを追加しています。私が抱えている問題は、セル列内のデータを比較して、その列のグループ内で最高のパフォーマーと最悪のパフォーマーを強調する方法を見つけることです。

ここに私が使用しているJavaScript関数があります。

function performanceMetricsLoad() {
var records = storePerformanceMetricsData.getRecordsValues();
var groupTracker = null;
var assetTracker = null;
var htmlStr;
htmlStr = "<table class='TableStyles'><thead class='HeaderStyles'><tr><th width='400'>Name</th><th width='110'>1 month Cumulative Performance to "
            + records[0].DatetimeRecorded.format("F j, Y") + "</th><th width='110'>3 month Cumulative Performance to "
            + records[0].DatetimeRecorded.format("F j, Y") + "</th><th width='110'>6 month Cumulative Performance to "
            + records[0].DatetimeRecorded.format("F j, Y") + "</th><th width='110'>12 month Cumulative Performance to " 
            + records[0].DatetimeRecorded.format("F j, Y") + "</th></tr></thead><tbody>";

for (var i = 0; i < records.length; i++) {

    if (groupTracker != records[i].ClassOption) {
        htmlStr += "<tr>" + "<td class='GroupStyleCSS' colspan='5'>" 
        + records[i].Diversification + "</td></tr>";
        groupTracker = records[i].ClassOption;
    }

    if (groupTracker == records[i].ClassOption) {
        htmlStr += "<tr>" + "<td class='RecordCssStyle'>" + records[i].AssetLongName
        + "</td>"+ "<td class='RecDiv'>" + records[i].TotalReturn1m.toFixed(2)
        + "</td>" + "<td class='RecDiv'>" + records[i].TotalReturn3m.toFixed(2)
        + "</td>" + "<td class='RecDiv'>" + records[i].TotalReturn6m.toFixed(2) 
        + "</td>" + "<td class='RecDiv'>" + records[i].TotalReturn12m.toFixed(2) + "</tr>"; 
        assetTracker = records[i].AssetLongName;
    }
}

htmlStr += "</tbody></table>";
createRow("", htmlStr);
frmMetrics.doLayout();

}

function createRow(cls, text) {
frmMetrics.add(new Ext.BoxComponent({
    cls: cls,
    html: "<div>" + text + "</div>"
}));

}

情報は EXT formPanel に出力されます。

私が抱えている問題は、グループ内の列内で最高のパフォーマーと最低のパフォーマーを強調表示する方法を見つけるために必要な情報を出力していることです...

テーブルは、SQL クエリを使用して要求された情報に応じて、上部に 5 列、ファンド名の左側に最大 10 グループを出力します。

このコードの現在の状態でこれを行う方法を知っている人はいますか? 私は別の外部関数を使用することを考えていましたが、おそらくいくつかの if ステートメントが異なる css クラスを選択することを考えていました...どんな助けも大歓迎です。どうもありがとう。

スクリーンショットがなくて申し訳ありません。いくつか含めようとしましたが、そうする前に評判スコアを 10 にする必要があるようです...

4

1 に答える 1