获取记录数在剑道电网dataSource.read后 [英] Get record count in Kendo Grid after dataSource.read

查看:589
本文介绍了获取记录数在剑道电网dataSource.read后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够读取(刷新)之后,从我的剑道电网推记录数。

I want to be able to push the record count from my Kendo grid after read (refresh).

这里是我的剑道网格:

    @(Html.Kendo().Grid(Model)
      .Name("SearchWindowGrid")
      .Columns(columns =>
          {
              columns.Bound(p => p.SYSTEM_ITEMS_SEGMENT1).Hidden();
          })
      .ClientRowTemplate(
          "<tr>" +
            "<td>" +
                "<span><b>#: SYSTEM_ITEMS_SEGMENT1#</b></span>&nbsp;<br/>" +
                "<span>#: DESCRIPTION# </span>" +
            "</td>" +
          "</tr>"
      )
      .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("PopulateSearchWindow", "Item").Data("additionalSearchWindowInfo"))
        .Events(ev => ev.Error("onErrorSearchWindow"))
      )
      .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
      .Scrollable(s => s.Enabled(true).Height(450))
  )

我的控制器动作:

    public ActionResult PopulateSearchWindow([DataSourceRequest] DataSourceRequest request, string option, string searchText, string searchDesc)
    {
        try
        {
            var derps= _idg.SearchItems(searchText, searchDesc, _adg.OrganizationCode).ToList();

            return Json(derps.ToDataSourceResult(request, ModelState));
        }
        catch (Exception e)
        {
            ModelState.AddModelError("ExceptionErrors", e.Message);
            return Json(new List<Derp>().ToDataSourceResult(request, ModelState));
        }
    }

这里是我的功能,迫使数据刷新:

    function refreshData(){
        $("#SearchWindowGrid").data("kendoGrid").dataSource.read();
        //TODO: get the total count and push to #countElement
        var count = $("#SearchWindowGrid").data("kendoGrid").length; //not sure what to do here
        $("#countElement").val(count);
    }

在哪里我把我的TODO在jQuery的功能我希望能够得到的行数和推这个数字到一个特定的elemnt我的网页上。

Where I put my TODO in the jQuery function I want to be able to get the number of rows and push that number into a specific elemnt on my page.

推荐答案

据这里的API参考

数据源具有总共()函数。所以,你应该能够做到以下几点,在理论上:

the dataSource has a total() function. So you should be able to do the following, in theory:

function refreshData(){
        var grid = $("#SearchWindowGrid").data("kendoGrid");
        grid.dataSource.read();
        var count = grid.dataSource.total();
        $("#countElement").val(count);
    }

这篇关于获取记录数在剑道电网dataSource.read后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆