2014-07-21 39 views
1

我有一個Kendo網格,並希望使用兩列克里特ClientFooterTemplate(Value2)。KendoUI網格自定義頁腳使用兩個或多個列與MVC包裝

所以,我有:

@(Html.Kendo().Grid<MyGridDto>().Name("grid") 
        .Columns(columns => 
        { 
         columns.Bound(p => p.Value1) 
         .ClientFooterTemplate("#= sum #"); 
         columns.Bound(p => p.Value2); 
         .ClientFooterTemplate (HERE I WANT TO GET SUM OF VALUE3/SUM VALUE 2) 
         columns.Bound(p => p.Value3).Visible(false); 

        } 
        .DataSource(dataSource => dataSource 
         .Ajax() 
         .Aggregates(aggregates => 
         { 
          aggregates.Add(p => p.Value1).Sum(); 
          aggregates.Add(p => p.Value2).Sum(); 
          aggregates.Add(p => p.Value3).Sum(); 
         })    
         .Read(read => read.Action("List", "MyController))      ) 
) 

MyGridDto

public class MyGridDto 
{ 
    public decimal Value1 { get; set; } 
    public decimal Value2 { get; set; } 
    public decimal Value3 { get; set; }   
} 

我想顯示使用值2的值3 /總和的總和值2頁腳。我怎樣才能做到這一點?

<div class="k-grid k-widget"> 
    <table class="k-focusable" id="totals" > 
     <tr> 
      <td/> 
      <td/> 
      <td> 
       Total price: <span data-bind="text: priceTotal" /> 
      </td> 
     </tr> 
    </table> 
</div> 

請參閱下面的例子:

感謝

回答

1

您可以通過獲取ValueComputed的值插入數據源請求結束一個臨時變量,並在添加尾行如下做到這一點更多信息:

Kendo UI Grid With Table Footer by Darren Bell

您可能需要都獨立創建數據源,將有綁定v iewmodel一旦創建數據源。


編輯:

按你更新,我已創建使用相同的邏輯按照上表頁腳例子供參考的工作樣品。請通過下面的鏈接找到的工作示例:

Kendo UI Grid Custom Calculated Footer

不要讓我知道這是不是你在找什麼!

編輯2:

Client Footer only

+0

感謝您的答覆。我的問題是錯誤的,所以我編輯了更正的信息。你知道我該怎麼做? – Paul

+1

嗨@Paul,我已經更新瞭解決方案,並根據您的問題提供了一個工作示例。如果您有任何問題,請告知我。 –

+0

謝謝,但問題是我已經有了腳註(由ClientFooterTemplate創建)。它的工作很好,當我只用一列的價值工作。有什麼方法可以訪問ClientFooterTemplate中其他列的總和嗎? – Paul

相關問題