Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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
Javascript 可滚动{Virtual:true}的延迟加载在剑道UI网格中不起作用_Javascript_Jquery_Kendo Ui_Kendo Grid - Fatal编程技术网

Javascript 可滚动{Virtual:true}的延迟加载在剑道UI网格中不起作用

Javascript 可滚动{Virtual:true}的延迟加载在剑道UI网格中不起作用,javascript,jquery,kendo-ui,kendo-grid,Javascript,Jquery,Kendo Ui,Kendo Grid,我面临一个在KendoUIGrid中实现延迟加载的问题。 我添加了可滚动虚拟属性和后端服务器端代码来处理它,但问题是在添加可滚动属性后,我无法在网格中看到滚动条。 即使是选定的20页大小的行也会从网格底部消失到隐藏的溢出区域中 这是我的密码 var managecustomerGrid = $("#customerGrid").kendoGrid({ dataSource: { schema: { data: "results",

我面临一个在KendoUIGrid中实现延迟加载的问题。 我添加了可滚动虚拟属性和后端服务器端代码来处理它,但问题是在添加可滚动属性后,我无法在网格中看到滚动条。 即使是选定的20页大小的行也会从网格底部消失到隐藏的溢出区域中

这是我的密码

var managecustomerGrid = $("#customerGrid").kendoGrid({
    dataSource: {
        schema: {
            data: "results",
            total : "totalRecords",
            model: {
                id: "SRNUMBER",
                fields: {
                    SRNUMBER : {type: 'number'},
                    CUSTOMERNAME : {type: 'string'},
                    DATEPAID : {type: 'string'}
                }
            }
        },
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true,
        pageSize: 20,
        batch: false,
        transport: {
            read: {
                type: "POST",
                url: "/customer/customer.cfc",
                dataType: "json",
                error: function (xhr, error) {
                    alert('Error In Getting Customer Information.');
                }
            },
            parameterMap: function(options, type) {
                return {
                    ntPageNumber: options.page,
                    ntRowLimit: options.pageSize,
                    vcSortOrder: JSON.stringify(options.sort),
                    vcFilterCondition: JSON.stringify(options.filter)
                }
            }
        }
    },
    toolbar: kendo.template($("#template").html()),
    height: 600,
    scrollable: {
        virtual: true
    },
    filterable: {
        operators: {
            string: {
                    contains: "Contains",
                    startswith: "Starts with",
                    endswith: "Ends with",
                    eq: "Is equal to",
                    doesnotcontain: "Doesn't contain"
            }
        }
    },
    sortable: true,
    columns: [      
        { field: "SRNUMBER", title: "SR No.", width: "80px", template: "<span id='#=SRNUMBER#'>#=SRNUMBER#</span>"},
        { field: "CUSTOMERNAME", title: "Customer Name", width: "110px"},
        { field: "DATEPAID", title: "Date", width: "110px"},
        { command: ["edit","detail","cancel"], title: "&nbsp;",  title: "Actions", width: "130px", filterable: false, sortable: false}
    ]
});

如果有人发现任何问题,请告诉我。我无法获得它。

剑道网格实际上不支持从盒子中惰性加载。相反,只创建一个无分页的空白滚动网格,然后用ajax调用填充数据可能更容易。可以使用$.merge将数据追加到数据数组中,对性能几乎没有影响

$.ajax({
url: '/getNextData',
data: { filter: 'foo', lastLoaded: $("#Grid").data("kendoGrid").dataSource.at($("#Grid").data("kendoGrid").dataSource.total()-1).ID },
dataType: "json",
success: function (newData) {
    $("#Grid").data("kendoGrid").dataSource.data($.merge($("#Grid").data("kendoGrid").dataSource.data(), newData))
},
error: function (e) { console.log(e); }
});

在这个ajax示例中,我根据网格中当前的最后一项和过滤器加载下一个数据。我只是将响应附加到当前加载的数据。

我面临同样的问题,我的问题是控制器代码。在这里,我张贴我的控制器,希望有一天它会帮助别人

 public JsonResult GetJson(int? projectid,int skip, int take, int pageSize, int page)
    {

        using (sqlCon)
        {
            var myData = sqlCon.Query<Device>("Select  * from workbook.dbo.TargetList", new { projectid = projectid });
            var data = myData .Skip(skip).Take(pageSize).ToList();
            var total = myData .Count();
            var json = new { data = myData };
            var jsonResult = Json(new {data= data, total= total}, JsonRequestBehavior.AllowGet);
            jsonResult.MaxJsonLength = int.MaxValue;
            return jsonResult;
        }

    }