3

以下のように、asp.net WebフォームにTelerik RadGridがあります。

MasterTableView
           DetailTables -> GridTableView

その詳細テーブルには、以下のような列があります。

                            <telerik:GridTableView runat="server" DataKeyNames="ID,Customer_ID,CardType_ID,OrderStatus_ID"
                                DataSourceID="sdsOrders" AllowFilteringByColumn="True" 
                                AllowMultiColumnSorting="True" AllowSorting="True" ShowFooter="True" OnDataBinding="GridTableView_DataBinding">  
...   

                            <telerik:GridBoundColumn DataField="TotalPrice" DataType="System.Int32" FilterControlAltText="Filter TotalPrice column"
                                HeaderText="TotalPrice" SortExpression="TotalPrice" 
                                UniqueName="TotalPrice" AllowFiltering="False" FooterText="Sum: " Aggregate="Sum">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                            </telerik:GridBoundColumn>

フッターのフッターテキスト(Sum)とその(Sum)の色を変えたいです。
MasterTableView の DataBoundColumns の場合、以下のコードが機能します。

protected void GridTableView_DataBinding(object sender, EventArgs e)
{
    GridBoundColumn TotalPrice = grdCustomers.MasterTableView.GetColumnSafe("TotalPrice") as GridBoundColumn;
    TotalPrice.FooterAggregateFormatString = "<span class=\"AggregateTitleColor\">Sum : </span>" + "{0:#,0 ;#,0- }";
    TotalPrice.FooterStyle.ForeColor = ColorTranslator.FromHtml("blue");
}

DetailTable の TotalPrice のコードを書き直すにはどうすればよいですか?

前もって感謝します

4

2 に答える 2

1

私は答えを見つけました:
最初にMasterTableViewでDataBindingを使用する必要があります。
次のようなコードを書き直します。

protected void MasterTableView_DataBinding(object sender, EventArgs e)  <- Pay Attention Here
{
    GridBoundColumn TotalPrice = grdCustomers.MasterTableView.DetailTables[0].GetColumnSafe("TotalPrice") as GridBoundColumn;
    TotalPrice.FooterAggregateFormatString = "<span class=\"AggregateTitleColor\">Sum : </span>" + "{0:#,0 ;#,0- }";
    TotalPrice.FooterStyle.ForeColor = ColorTranslator.FromHtml("blue");
}

これで完了です。

于 2012-06-27T21:54:30.050 に答える
0

RAD Grid コントロールの Totalingのドキュメントを参照してください。合計を表示する方法は既にご存じだと思いますが、FooterStyle 属性を使用してフッターの色を変更することを示す C# および ASP コードのすばらしいチャンクがあります。

于 2012-06-27T20:59:24.030 に答える