Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Telerik网格:使用Ajax绑定检索行数_Ajax_Asp.net Mvc_Telerik - Fatal编程技术网

Telerik网格:使用Ajax绑定检索行数

Telerik网格:使用Ajax绑定检索行数,ajax,asp.net-mvc,telerik,Ajax,Asp.net Mvc,Telerik,如何在Telerik ASP.Net MVC网格中使用Ajax绑定访问网格行数? 我需要在页脚中显示总计,请参见下面的代码段。总数必须在插入和删除时更新 对于服务器绑定,存在@Model.Count()。如何使用Ajax绑定实现同样的功能 谢谢大家! @{ Html.Telerik() .Grid<ContractMonth>() .Name("contractMonthGrid") .DataBinding(dataB

如何在Telerik ASP.Net MVC网格中使用Ajax绑定访问网格行数? 我需要在页脚中显示总计,请参见下面的代码段。总数必须在插入和删除时更新

对于服务器绑定,存在@Model.Count()。如何使用Ajax绑定实现同样的功能

谢谢大家!

    @{
    Html.Telerik()
        .Grid<ContractMonth>()
        .Name("contractMonthGrid")
        .DataBinding(dataBinding => dataBinding
            .Ajax()
            .Select("_AjaxBinding", "ContractMonth")
            .Insert("_AjaxInsert", "ContractMonth")
            .Delete("_AjaxDelete", "ContractMonth")
            )
        .DataKeys(keys => keys.Add(c => c.Id))
        .ToolBar(commands => commands.Insert())
        .Columns(columns =>
        {
            columns.Bound(o => o.StartDate).EditorTemplateName("Date").FooterTemplate(@<text>@Model.Count()</text>);
@{
Html.Telerik()
.Grid()
.名称(“合同蒙特格里德”)
.DataBinding(DataBinding=>DataBinding
.Ajax()
.选择(“\u AjaxBinding”,“ContractMonth”)
.插入(“\u AjaxInsert”,“合同月”)
.Delete(“\u AjaxDelete”,“ContractMonth”)
)
.DataKeys(keys=>keys.Add(c=>c.Id))
.ToolBar(commands=>commands.Insert())
.列(列=>
{
columns.Bound(o=>o.StartDate).EditorTemplateName(“日期”).FooterTemplate(@@Model.Count());

Telerik MVC网格支持服务器和:

支持以下聚合:

  • 平均值
  • 计数
  • 马克斯
  • 总数
要指定列的聚合,请使用聚合方法

因此,在您的示例中:

.Columns(columns =>
    {
        columns.Bound(o => o.StartDate)
               .EditorTemplateName("Date")
               .Aggregate(aggregates => aggregates.Count())
               .FooterTemplate(@<text>@item.Count</text>)
               .ClientFooterTemplate("<#= Count #>");
    }
.Columns(Columns=>
{
columns.Bound(o=>o.StartDate)
.EditorTemplateName(“日期”)
.Aggregate(aggregates=>aggregates.Count())
.FooterTemplate(@@item.Count)
.ClientFooterTemplate(“”);
}
如果需要网格“外部”的行数,可以使用网格的:


$(函数(){
var totalRows=$(“#contractMonthGrid”).data(“tGrid”).total;
//对totalRows做点什么
});

Telerik MVC网格支持服务器和:

支持以下聚合:

  • 平均值
  • 计数
  • 马克斯
  • 总数
要指定列的聚合,请使用聚合方法

因此,在您的示例中:

.Columns(columns =>
    {
        columns.Bound(o => o.StartDate)
               .EditorTemplateName("Date")
               .Aggregate(aggregates => aggregates.Count())
               .FooterTemplate(@<text>@item.Count</text>)
               .ClientFooterTemplate("<#= Count #>");
    }
.Columns(Columns=>
{
columns.Bound(o=>o.StartDate)
.EditorTemplateName(“日期”)
.Aggregate(aggregates=>aggregates.Count())
.FooterTemplate(@@item.Count)
.ClientFooterTemplate(“”);
}
如果需要网格“外部”的行数,可以使用网格的:


$(函数(){
var totalRows=$(“#contractMonthGrid”).data(“tGrid”).total;
//对totalRows做点什么
});

感谢您提供的代码和指向Ajax聚合文档的链接!感谢您提供的代码和指向Ajax聚合文档的链接!