首页 > 解决方案 > 如何在模式弹出窗口中使用 Kendo.Grid() 显示进度加载指示器?

问题描述

Grid我在我的内部定义了一个Partial View加载到模式弹出窗口中的内容。

这是的一部分Grid

 @(Html.Kendo().Grid(Model.ReportReversalsData)
     .Name("MyGrid")
     .
     .
     .DataSource(ds => ds
                .Ajax()
                .Events(e => e.Error("ShowError"))
                .Read(r => r.Action("MyMethod", "MyController", Model))
     )
)

现在,每次数据加载时,我都想在 Grid 中插入一个进度加载指示器。

我试图定义一个在网格事件上showLoading调用的 javascript 方法:RequestStart

.Events(e => e.Error("CheckError").RequestStart('showLoading'))

这是showLoading功能和一些.css样式所需的kendo.ui.progress

<style>
    .k-grid-content > .k-loading-mask
    {
        visibility: hidden;
    }

    .k-grid > .k-loading-mask
    {
        z-index: 2;
    }

    .k-grid > .k-loading-mask > .k-loading-color
    {
        opacity: .7;
    }

</style>

<script>
    function showLoading()
    {
       kendo.ui.progress("#MyGrid", true)
    }
</script>

但是,我收到一个错误:

对象不支持属性或方法“查找”

我错过了什么,或者我的方法完全错误,还有其他方法可以做到这一点?

标签: asp.net-mvckendo-uikendo-grid

解决方案


不要尝试使用纯文本 id,而是使用实际的 kendo 元素:

function showLoading()
{
    var myGrid = $("#myGrid").getKendoGrid();
    kendo.ui.progress(myGrid, true);
}

推荐阅读