wice_grid icon indicating copy to clipboard operation
wice_grid copied to clipboard

Parameter total_entries doesnt work?

Open radeno opened this issue 9 years ago • 3 comments

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!

radeno avatar Sep 24 '15 13:09 radeno

: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

leikind avatar Sep 25 '15 19:09 leikind

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?

radeno avatar Sep 26 '15 08:09 radeno

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.

leikind avatar Sep 26 '15 10:09 leikind