hjalmers / angular-generic-table

A generic table for Angular 2+. Generic table uses standard markup for tables ie. table, tr and td elements etc. and has support for expanding rows, global search, filters, sorting, pagination, export to CSV, column clicks, custom column rendering, custom export values.
https://hjalmers.github.io/angular-generic-table/
MIT License
105 stars 55 forks source link

Lazy loading with Checkbox selection not working if record count is less than 100 or more than 100 #251

Closed LokeshBoran closed 6 years ago

LokeshBoran commented 6 years ago

The last checkbox issue is fixed but now if let say my API returns 12 records and the page size is 10 then checkbox functionality is not working. Please check example.

Step to reproduce -

Simply click on select/deselect all checkbox it won't work.

It only works if

 recordsAll:  100,
          recordsAfterSearch: 100,
          recordsAfterFilter: 100,
          recordLength: 10
hjalmers commented 6 years ago

Yeah, this is a bug for sure, I was a bit fast with the last fix and I realised I missed a thing now when I took another look at it. To make this work good I think the server needs to know when the client thinks all rows are selected. Say I check all rows and click delete, in my opinion it should delete all rows not just the once visible. So I'm thinking about adding a property to store the state of the client, something like lazyAllSelected that can be true or false. If true, all rows will appear to be checked when fetched by the sever even though the selectedRows array will only hold the rows that have actually been fetched. Does that make sense?

LokeshBoran commented 6 years ago

Yes, It is perfectly fine. As an end user let say I clicked on select all then it should select only visible records or action should be performed on visible records. Or it should be configurable. I think lazyAllSelected will be used for both cases.

jigar-g commented 6 years ago

Hey, @LokeshBoran I am Facing the same Issue. Did you have any Solution for this?

LokeshBoran commented 6 years ago

@jigar-g No, but I think @hjalmers fixing this in next build.

hjalmers commented 6 years ago

I've added a fix for this in v4.16.0 so please give it a try @LokeshBoran and @jigar-g and let me know if you have any issues or questions regarding the implementation. If the checkbox in the table header is checked, all rows that are fetched will be added to the selection once loaded. The "select all" checkbox will be unchecked when a row is unselected i.e. when not all rows are selected anymore. Even though the table will know which records have been selected client side, it's important to look at the lazyAllSelected property on the table if the server wants to know if the client thinks that all rows are selected or not.