簡體   English   中英

劍道網格分頁不起作用

[英]kendo grid paging does not work

如何在Kendo網格的total屬性中分配行號? 我用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  ....

根據我在您的代碼中看到的, total功能應為:

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

您從PHP返回的是一個JSON對象,該對象在名為list的字段中包含一個array ,這是一個JSON對象(在KendoUI total一次)。 因此,對該數組的引用是response.list和長度response.list.length

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM