KoGrid icon indicating copy to clipboard operation
KoGrid copied to clipboard

Total Items is 1 even if there are no rows

Open davidjsilva opened this issue 12 years ago • 2 comments

Kogrid will display total items of 1 in the footer even if the number of rows in the grid is 0. I think I have nailed it down to this piece of code:

self.maxRows = ko.observable(Math.max(self.config.pagingOptions.totalServerItems() || self.sortedData().length, 1));

Why is maxRows defaulted to 1?

davidjsilva avatar Jan 17 '13 23:01 davidjsilva

The value displayed is the computed observable self.maxRowsDisplay

It seems to work if it is changed from:

self.maxRowsDisplay = ko.computed(function () {
    return self.maxRows;
});

to

self.maxRowsDisplay = ko.computed(function () {
    return Math.max(self.config.pagingOptions.totalServerItems() || self.sortedData().length, 0);
});

pnayak avatar Mar 19 '13 16:03 pnayak

I tried the above solution and it didn't work. But changing the 1 to 0 in the math function in the above solution along with changing it in below code worked.

self.maxPages = ko.computed(function () { self.maxRows(Math.max(self.config.pagingOptions.totalServerItems() || self.sortedData().length, 0)); return Math.ceil(self.maxRows() / self.pagingOptions.pageSize()); });

The important question is, making changes in the source file a good idea. That could get overwritten with by the next update.

amarendra-parab avatar Oct 20 '14 11:10 amarendra-parab