KendoUI Grid客户端分页总共显示零页面

时间:2013-12-06 16:59:10

标签: javascript kendo-ui kendo-grid

我创建了kendo分页网格并从服务器加载所有数据,然后使用trasport配置在网格上显示。但它总是在网格上显示页面零号。并在页脚上显示“没有要显示的项目”的措辞。 这是我的编码:

<div id="grid"></div>

    $(function(){

        var data_scheme = {
            data: "expert",
            model: {
                id: "expertId",
                fields: {
                    expertId: { type: 'string',nullable: true },
                    name: { type: 'string', nullable: false, editable: true,
                        validation: { required: true, validationMessage: 'xxxxxxxxxxxxxxxx'}
                    },
                    address: { type: 'string', nullable: false, editable: true },
                    email: { type: 'string', nullable: false, editable: true,
                        validation: { required: false, email: true, validationMessage:'xxxxxxxxxxxxxxxx'  }
                    },
                    phone: { type: 'string', nullable: false, editable: true }
                }
            },
            errors: "errors"
        };

        var dataSourceE = {
            transport: {
                read: { url: '<?php echo site_url('expert/listing'); ?>', contentType: 'application/json' }
            },
            error: function(e) { alert(e.errors); },
            schema: data_scheme,
            batch: false,
            pageSize: 2,
            serverPaging: false,
            total: "total"
        };



        var th_attribute = { 'class': 'table-header-cell', style: 'font-weight:bold;text-align: center' };
        var td_attribute = { 'class': 'table-cell', style: 'text-align: center'};
        var tdleft_attribute = { 'class': 'table-cell', style: 'text-align: left'};
        $('#grid').kendoGrid({
            dataSource: dataSourceE,
            toolbar: ["create"],
            editable: 'inline',
            selectable: 'row',
            resizable: true,
            sortable: true,
            serverAggregates:true,
            pageable: {
                input: true,
                numeric: false,
                refresh: true
            },
            columns: [
                {field: 'name', title: 'Name', headerAttributes: th_attribute, attributes: tdleft_attribute},
                {field: 'expertId', hidden:true, title: 'ExpertId', headerAttributes: th_attribute, attributes: tdleft_attribute},
                {field: 'address', title: 'Address', width: 200, headerAttributes: th_attribute, attributes: tdleft_attribute},
                {field: 'email', title: 'Email', width: 180, headerAttributes: th_attribute, attributes: tdleft_attribute,
                    template: '<a href="mailto:#=email#">#=email#</a>'},
                {field: 'phone', title: 'Phone', width: 180,headerAttributes: th_attribute, attributes: tdleft_attribute},
                {command: ["edit", "destroy"], title: "&nbsp;", width: 180, headerAttributes: th_attribute}
            ]
        });

    });

这是来自调用localhost / expert / index页面的json:

    {"expert":[
{"expertId":"1","name":"aaaaaaa","address":"ssssssssss","phone":"8082201270","email":"sman@hotmail.com"},
{"expertId":"2","name":"bbbbbbb","address":"ssssssssss","phone":"8082201270","email":"ganjana@hotmail.com"},
{"expertId":"3","name":"ccccccc","address":"ssssssssss","phone":"8082201270","email":"ganjana2@hotmail.com"},
{"expertId":"4","name":"ddddddd","address":"ssssssssss","phone":"8082201270","email":"asdf@asdf.comss"},
{"expertId":"5","name":"eeeeeee","address":"ssssssssss","phone":"8082201270","email":"dddddddd@asdf.com"},
{"expertId":"6","name":"fffffff","address":"ssssssssss","phone":"8082201270","email":"asdfasdff@ad.com"},
{"expertId":"7","name":"ggggggg","address":"ssssssssss","phone":"8082201270","email":"adfadf@www.comaS"},
{"expertId":"8","name":"hhhhhhh","address":"ssssssssss","phone":"8082201270","email":"sfdhdhj@ass.com"},
{"expertId":"9","name":"kkkkkkk","address":"ssssssssss","phone":"8082201270","email":"asdf@eed.com"}
], "total":9}

我尝试在谷歌上搜索解决方案并更改代码遵循这些解决方案,但还没有工作。

2 个答案:

答案 0 :(得分:2)

您可以尝试在total:"total"之后将errors:"errors"放在data_scheme中,如下所示:

errors:"errors",
total:"total"

基本上,totalschema对象上的属性。 (这就是我的工作方式:)。

由于

答案 1 :(得分:0)

抱歉,我可以按照solution修复此错误。 通过将总数从数据源移动到模式。