This is a migrated thread and some comments may be shown as answers.

[Solved] Possible pageSize bug with kendo angular grid and ObservableArray

2 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 10 Sep 2014, 12:46 AM
I'm using a kendo angular grid on a page. The config is this:

$scope.gridData = new kendo.data.ObservableArray($scope.rowData);
          $scope.gridOptions = {
                    columns: [{
                        field: "itemType",
                        title: '<i class=\'fa fa-file-o\'></i>',
                        sortable: false,
                        width: 40
                    },{
                        field: "displayName",
                        title: "Name"
                    }, {
                        field: "owner",
                        title: "Owner"
                    }, {
                        field: "tags",
                        title: "Tags",
                        sortable: {
                            compare: function(data) {
                                return _.filter(data.tags, function(tagObj) {
                                    return (tagObj.state === 'Accepted' || tagObj.state === 'Suggested');
                                }).length;
                            }
                        }
                    }, {
                        field: "fileType",
                        title: "Content Type"
                    }, {
                        field: "size",
                        title: "Size",
                        width: 70
                    }, {
                        field: "lastModificationTime",
                        title: "Last Modified"
                    }],
                    sortable: {
                        mode: "single",
                        allowUnsort: false
                    },
                    columnMenu: true,
                    reorderable: true,
                    resizable: true,
                    selectable: "row",
                    pageable: {
                        pageSize: 25,
                        pageSizes: [25, 50, 100],
                        previousNext: true
                    },
                    rowTemplate: kendo.template($("#browseListGrid").html()),
                    dataSource: $scope.gridData
                };


So if I use this config to generate a grid, the pageSize defaults to the length of the $scope.gridData. If I use $scope.rowData as the dataSource, the pageSize actually works. I have absolutely no idea why this is the way it is...my understanding is that it should work with the array wrapped with ObservableArray. I have reproduced it in the following:

http://dojo.telerik.com/@yazdog8/IlEF





2 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 10 Sep 2014, 02:56 PM
Hello Joe,

The grid is configured to check if the passed data is a simple array, and then set the data directly, but does not check for the observableArray option. This is why you will need to pass the observableArray to the data property of the DataSource, as in this updated example:

http://dojo.telerik.com/UXIL

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
JSON
Top achievements
Rank 1
answered on 10 Sep 2014, 10:20 PM
That solved the problem, thanks.
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
JSON
Top achievements
Rank 1
Share this question
or