即使记录在那里,剑道寻呼机(可分页)显示“无要显示的项目”

时间:2017-05-17 09:12:58

标签: javascript angularjs kendo-ui pagination kendo-grid

这里我使用了Angular-JS的Kendo-UI。

在Kendo网格表上集成Pagination(可分页)时遇到问题,即使正确加载数据(记录),也会显示“无要显示的项目”。

不确定它有什么问题,任何帮助都会被挪用......

以下是我用来加载/初始化数据网格的函数。

function getProjectsAtAGlance() {
                $scope.gridOptions = {
                    scrollable: false,
                    sortable: true,
                    pageable: {
                        pageSizes: [5, 10, 15, 20, 25, 50]
                    },
                    change: function (e) {
                        $scope.pageSize = $scope.gridOptions.dataSource.pageSize();
                    },
                    dataSource: {
                        serverPaging: true,
                        transport: {
                            read: function (options) {

                                $scope.options = options;

                                var filters = {
                                    skip: options.data.skip,
                                    take: options.data.take,
                                    sortBy: $scope.sortBy,
                                    projectGlanceIncludeArchived: $scope.includeArchivedProjects,
                                    projectGlanceExcludeProjectsWithNoBudgets: $scope.excludeProjectsWithNoBudgets
                                };

                                $http.post("/Home/ProjectsAtAGlanceReport", filters)
                                    .success(function (result) {
                                        var projects = result.projects;

                                        for (var i = 0; i < projects.length; i++) {
                                            var project = projects[i];
                                            project.startDate = moment(projects[i].startDate).format("L");
                                            project.endDate = moment(projects[i].endDate).format("L");
                                        }

                                        options.success(projects);

                                    })
                                    .error(function (error) {
                                        console.log(error);
                                    });
                            }
                        },
                        pageSize: $scope.pageSize,

                        schema: {
                            total: function (respose) {
                                return $scope.data;
                            },

                            model: {
                                fields: {
                                    name: {
                                        editable: false,
                                        nullable: true
                                    },
                                    resourceCount: {
                                        editable: false,
                                        nullable: true
                                    },
                                    clientName: {
                                        editable: false,
                                        nullable: true
                                    },
                                    startDate: {
                                        editable: false,
                                        nullable: true
                                    },
                                    endDate: {
                                        editable: false,
                                        nullable: true
                                    },
                                    projectId: {
                                        editable: false,
                                        nullable: true
                                    },
                                    projectedBudgetPercentage: {
                                        defaultValue: 100
                                    },
                                    defaultValue: {
                                        totalBudget: 0,
                                        totalHours: 0,
                                        burnedBudget: 0,
                                        burnedHours: 0,
                                        projectedBudget: 0,                                         
                                        projectedHours: 0,
                                        projectedHoursPercentage: 0,
                                        remainingBudget: 0,
                                        remainingBudgetPercentage: 0,
                                        remainingHours: 0,
                                        remainingHoursPercentage: 0
                                    }
                                }
                            }
                        }
                    },

                    columns: [
                        {
                            template: "<div class='name-column'>" +
                                "<p><a class='highlighted-blue' href='/Projects/ProjectAdmin/{{dataItem.projectId}}'>{{dataItem.name}}</a></p>" +
                                "<small>{{dataItem.clientName}}</small>" +
                                "<small ng-if=\"dataItem.startDate !== 'Invalid date'\">{{dataItem.startDate}} - {{dataItem.endDate}}</small>" +
                                "<small ng-if=\"dataItem.startDate === 'Invalid date'\"><i class='fa fa-exclamation-triangle text-danger'></i> Start date and end date are not defined.</small>" +
                                "<small>{{dataItem.resourceCount}} Resources</small></div>"

                        },
                        {
                            template: kendo.template($("#kendoProgressBarColumnTemplate").html())
                        },
                        {
                            template: "<accuracy-gauge-per-project accuracy='dataItem.accuracy'></accuracy-gauge-per-project>"
                        },
                        {
                            template:
                                "<p>{{dataItem.accuracy | percentage:0}} Accurate</p>" +
                                "<p>{{100-dataItem.accuracy | percentage:0}} Non Accurate</p>"
                        }
                    ]
                };
            }

以下是输出摘要以供参考。 Kendo Grid with Pagination

1 个答案:

答案 0 :(得分:1)

我认为pageSize属性需要在dataSource内声明,如下所示:

dataSource: {
    serverPaging: true,
    transport: {... // transport options
    },
    pageSize: $scope.pageSize // before end of dataSource       
},... // more grid stuff

根据documentation将您从schema.total返回的内容更改为return response.total