swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

Types of inputs not enforced, messes up paging when limit is string #614

Open ggowan opened 7 years ago

ggowan commented 7 years ago

I'm submitting a ... (check one with "x")

[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior If you create an ngx-datatable with attribute limit=10, page sizes are variable - when you advance to the second page you'll see unexpectedly large page size. The reason is that the limit comes through as a string because I didn't do [limit]=10, so then all the math is doing string concatenation instead of addition (i.e. 10+10 = 1010).

It took me a while to debug this because I'm a noob. It would be more forgiving if we could just convert all the inputs to the correct type, and save me having to type [limit] instead of limit.

Expected behavior setting limit=10 sets page size to 10 consistently on all pages.

Reproduction of the problem When I repro'd I didn't use a vertical scrollbar. Just set limit like this: <ngx-datatable [rows]="rows" [columns]="columns" limit=10 footerHeight=50

What is the motivation / use case for changing the behavior? Make it easier for people without much experience to use this component successfully.

Please tell us about your environment: Linux.

amcdnl commented 7 years ago

We should implement number parsing in the column helper here -> https://github.com/swimlane/ngx-datatable/blob/master/src/utils/column-helper.ts#L12-L50

Would you mind PR'n this change? We should handle min/max etc too.

coderek commented 7 years ago

Hi @amcdnl, I want to contribute to this repo and this seems like a good starting point. However regarding the issue, why to change the column helper given the problem is actually the attribute set on the table itself? Could you please enlighten me? Thanks!