jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
584 stars 228 forks source link

Allow to set a table alias on columns #389

Open mordaroso opened 3 years ago

mordaroso commented 3 years ago

I have to work with quite some big tables where we use information from various models. Often joining multiple information from the same table, but through a different association.

For example:

Group to have multiple Users
Group to belong to one User as an admin

And then showing a table like this:

User | Group name | Group admin

Inspired by the addition of Rails 6.1.1 to allow where clause reference association by alias name this PR tries to solve this issue by allowing to overwrite the table_alias of a particular column definition.

This solution should also solve the issue mentioned in https://github.com/jbox-web/ajax-datatables-rails/issues/363