代码之家  ›  专栏  ›  技术社区  ›  user3933053

kendo网格分页不起作用

  •  0
  • user3933053  · 技术社区  · 11 年前

    如何在kendo网格中分配总属性中的行数?我使用json填充数据:

    if ($result = mysqli_query($con,$sql)) {   
        while($obj = mysqli_fetch_object($result)) {
            $arr[] = $obj;
        }
    }
    echo "{\"list\":" .json_encode($arr). "}";      
    

    但是分页不适用于total=total或function! 我不知道我的网格问题在哪里!!

    $(document).ready(function () {
                    var record = 0;
                    var grid = $("#grid").kendoGrid({
    
                        dataSource: {
                            transport: {
                                read: {
                                    url: "<?php echo $path?>/contractors.php?m=read&f=subcat",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                data: "list",
                                model: {
                                    id: "id",
                                    fields: {
                                        company: { type: "string" },
                                        firstname: { type: "string" },
                                        lastname: { type: "string" }
    
                                    }
                                },
                                total: function (response) {
                                    return $(response.data).length;
                                }
    
                            },
                            pageSize: 20,
                            serverPaging: true
                        },
                        pageable: true  ....
    
    1 回复  |  直到 11 年前
        1
  •  0
  •   OnaBai    11 年前

    从我在你的代码中看到的, total 函数应为:

    total: function (response) {
        return response.list.length;
    }
    

    您从PHP返回的是一个JSON对象 array 在名为 list 这是一个JSON对象(在KendoUI中 全部的 ). 因此,对数组的引用是 response.list 和长度 response.list.length .