leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Parameter total_entries doesnt work? #258

Open radeno opened 8 years ago

radeno commented 8 years ago

Hi,

Is parameter :total_entries for initialize_grid just blind parameter? I see in code that you uses do_count method to count entries, which is alias for AR count method.

Is there any way how to override internal counting ? We use complex aggregated functions in SQL query and count method just wraps our sql code and it doest work anymore. We must use length method to count result.

Is there any solution how to override couting?

Regards!

leikind commented 8 years ago

:total_entries should be deleted, thank you for noticing this. It's a legacy option. Internal counting is not performed by count or do_count. It is Kaminari which does that

radeno commented 8 years ago

Understand,

maybe it is interesting to pass-in initialize_grid some Kaminari parameters. For example Kaminari has possibility to change count with :total_count parameter. Rails AR are not much smart when joins or group using native SQL commands instead symbols as association names.

For example we use SQL table view, it is much faster than multiple includes. This also with some aggregate functions in scopes and AR collapses because it doesnt know how to use COUNT properly on that query.

What do you think?

leikind commented 8 years ago

Well, I have nothing against an option which, if present, would be submitted to Kaminari as total_count. It's actually a very easy thing to implement. If you submit a PR I will merge it.