Kendo UI网格始终从页面0开始 [英] Kendo UI Grid Always Starts at Page 0

查看:67
本文介绍了Kendo UI网格始终从页面0开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Kendo UI网格,它总是从0开始.

I have a Kendo UI Grid and it's always starting at 0.

如果我更改列的排序,那么它将变为1并显示其他页码.

If I change the sort on a column then it goes to 1 and shows the other page numbers.

我在做什么错了?

这是我的代码:

$('#userGrid').kendoGrid({
                dataSource: {
                    pageSize: 5,
                    transport: {
                        read: {
                            url: ROOT+"user/user-list",
                        },
                        update: {
                            url: ROOT+"user/update-user",
                            dataType: "POST"
                        }
                    },
                    error: function(e) {
                        alert(e.responseText);
                    },
                    schema: {
                        data: "data",
                        model: {
                            id: 'id',
                            fields: {
                                username: {type: "string", editable: false},
                                type: {
                                    type: "number",
                                    editable: true,
                                    validation: {required: true}
                                },
                                level: {
                                    type: "number",
                                    editable: true,
                                    validation: {required: true}
                                },
                                firstName: {type: "string", editable: true},
                                middleName: {type: "string", editable: true},
                                lastName: {type: "string", editable: true},
                                DoB: {type: "date", editable: true},
                                dateStarted: {type: "date", editable: false},
                                enabled: {
                                    type: "number",
                                    editable: true,
                                    validation: {required: true}
                                },
                            }
                        }
                    }
                },
                toolbar: ["save", "cancel"],
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: false
                },
                editable:true,
                columns:
                [
                    {
                    field: "username",
                    width: 90,
                    title: "Username"
                    },
                    {
                    field: "type",
                    width: 50,
                    title: "Type"
                    },
                    {
                    field: "level",
                    width: 25,
                    title: "Level"
                    },
                    {
                    field: "firstName",
                    width: 50,
                    title: "First name"
                    },
                    {
                    field: "middleName",
                    width: 50,
                    title: "Middle name"
                    },
                    {
                    field: "lastName",
                    width: 50,
                    title: "Last name"
                    },
                    {
                    field: "DoB",
                    width: 40,
                    title: "DoB",
                    template: '#= kendo.toString(DoB,"dd/MM/yyyy") #'
                    },
                    {
                    field: "dateStarted",
                    width: 40,
                    title: "Started",
                    template: '#= kendo.toString(dateStarted,"dd/MM/yyyy") #'
                    },
                    {
                    field: "enabled",
                    width: 40,
                    title: "Enabled"
                    }
                ]
            })
        })
    }
) ;
})


{"data":[{"id":"1","username":"admin@eu","type":"1","level":"12","firstName":"Tom","middleName":"C","lastName":"Higgins","DoB":"0000-00-00","dateStarted":"0000-00-00","enabled":"0"},{"id":"36","username":"liam.spelman@euautomation.com","type":"4","level":"12","firstName":"Liam","middleName":"","lastName":"Spelman","DoB":"0000-00-00","dateStarted":"0000-00-00","enabled":"0"},{"id":"56","username":"adf@sadf.com","type":"4","level":"1","firstName":"asdf","middleName":"","lastName":"asdf","DoB":"1970-01-01","dateStarted":"0000-00-00","enabled":"0"},{"id":"57","username":"adf@saddf.com","type":"4","level":"1","firstName":"asdf","middleName":"","lastName":"asdf","DoB":"1970-01-01","dateStarted":"0000-00-00","enabled":"0"}], "rowcount": 4}

推荐答案

您的服务器是否返回total条记录?

Is your server returning the total number of records?

如果是,则将schema定义为(假设total_size是服务器返回记录总数的位置):

If it is, define the schema as (assuming that total_size is where the server is returning the total number of records):

schema   : {
    data: "data",
    total: "total_size",
    model: {
        ...
    }
}

如果没有,请尝试向schema添加一个total函数,该函数从data数组的大小获取它:

If not, try adding to your schema a total function that gets it from the size of data array:

schema   : {
    data: "data",
    total: function(data) {
        return data.data.length;
    },
    model: {
        ...
    }
}

这篇关于Kendo UI网格始终从页面0开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆