【问题标题】:KendoUI Grid custom footer using two or more column with MVC wrapperKendoUI Grid 自定义页脚使用带有 MVC 包装器的两列或更多列
【发布时间】:2014-07-21 17:25:29
【问题描述】:

我有一个 Kendo Grid,想使用两列来创建一个 ClientFooterTemplate (Value2)。

所以,我有:

@(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; }         
}

我想使用 Value3 的总和 / Value2 的总和来显示 Value2 页脚。我该怎么做?

谢谢

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-asp.net-mvc


    【解决方案1】:

    您可以通过将 ValueComputed 的值获取到数据源请求端的临时变量中并添加页脚行来实现这一点,如下所示:

     <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>
    

    请参阅以下示例了解更多信息:

    Kendo UI Grid With Table Footer by Darren Bell

    您可能需要单独创建数据源,并且必须在创建数据源后绑定视图模型。


    编辑:

    根据您的更新,我使用与前面表格页脚示例相同的逻辑创建了一个工作示例供您参考。请在以下链接中找到工作示例:

    Kendo UI Grid Custom Calculated Footer

    如果这不是您要找的,请告诉我!

    编辑 2:

    Client Footer only

    【讨论】:

    • 感谢您的回复。我的问题是错误的,所以我用更正的信息进行了编辑。你知道我该怎么做吗?
    • 嗨@Paul,我已经更新了解决方案并根据您更新的问题提供了一个工作示例。如果您有任何问题,请告诉我。
    • 谢谢,但问题是我已经有了页脚(由 ClientFooterTemplate 创建)。当我只使用一列的值时,它工作正常。有什么方法可以访问 ClientFooterTemplate 中其他列的总和?
    • 好的,如果是这样的话,那就简单多了。你可以调用任何js函数来为你获取值。如 footerTemplate: "Your Value: #= getsumDiv32() # ",我也更新了解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多