javascript - Kendo UI Grid 在初始读取时未显示微调器/加载图标

标签 javascript jquery asp.net-mvc kendo-ui kendo-grid

我已经设置了我的 kendo ui 网格以从返回 JSON 的 MVC 操作中读取数据。由于成本原因,我使用的是 Kendo 的免费版本,而不是特定于 MVC 的版本。

问题是当页面加载并完成网格的初始填充时,它不显示加载微调器。填充网格后,我转到另一个页面或对它显示的列进行排序。

如果我设置网格的高度参数,我会得到初始微调器,但网格只显示一行(应该显示 20 行)。

有谁知道为什么要设置高度参数?或者在不设置高度的情况下让微调器工作的任何方式。

我的剑道 javascript 代码:

$("#grid").kendoGrid({
        dataSource: new kendo.data.DataSource({
            transport: {
                read: url,
                parameterMap: function (options) {
                    var result = {
                        pageSize: options.pageSize,
                        skip: options.skip,
                        take: options.take,
                        page: options.page,
                    };

                    if (options.sort) {
                        for (var i = 0; i < options.sort.length; i++) {
                            result["sort[" + i + "].field"] = options.sort[i].field;
                            result["sort[" + i + "].dir"] = options.sort[i].dir;
                        }
                    }

                    return result;
                }
            },
            requestStart: function () {
                //kendo.ui.progress($("#loading"), true); <-- this works on initial load, but gives two spinners on every page or sort change
            },
            requestEnd: function () {
                //kendo.ui.progress($("#loading"), false);

            },
            pageSize: 20,
            serverPaging: true,
            serverSorting: true,
            schema: {
                total: "total", 
                data: "data"
            },
        }),
        height: "100%", <-- I want to avoid this as it renders the grid way to small
        sortable: true,
        pageable: {
            refresh: true,
            pageSizes: true,
            buttonCount: 5
        },
        columns: [
            {
                field: "PaymentRefId",
                title: "Id"
            },
            {
                field: "DueDate",
                title: "Due Date"
            },
            {
                field: "Credit",
                title: "Amount"
            },
            {
                field: "InvoiceGroupId",
                title: " ",
                sortable: false,
                template: '<a href="/InvoiceGroup/InvoiceGroupDetails2/#: InvoiceGroupId #">See details</a>'
            }
        ],
    });

最佳答案

我遇到了同样的问题。它实际上是在渲染微调器/进度条,但是因为网格内容区域最初没有高度,所以您看不到它。这对我有用。试一试:

// This forces the grids to have just al little height before the initial data is loaded. 
// Without this the loading progress bar / spinner won't be shown.
.k-grid-content {
    min-height: 200px;
}

关于javascript - Kendo UI Grid 在初始读取时未显示微调器/加载图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21114819/

相关文章:

c# - 在 View MVC.NET 中使用来自导入引用的类

javascript - 将表单数据和字符串列表发送到 Controller

javascript - 给定随机坐标点,构造确定边缘点的多边形

javascript - 如何使用 Node js 中的 API key 从 REST api 获取数据?

javascript - 通过 Ajax 在 URL 中传递变量

javascript - jQuery:使用切片选择元素

jquery - Shopify客群批发

jquery - 编写此代码的更好方法? jQuery

javascript - 如果在一页 mvc 上登录,则从所有页面注销用户

javascript - 如何在 Codeigniter 中使用 Ajax 将变量从 Controller 传递到 View ?