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
587 stars 228 forks source link

Is it possible hide/show column conditionally ? #391

Closed NeimadTL closed 2 years ago

NeimadTL commented 3 years ago

I know how to pass variable from my controller to the datatable like this: render json: UserDatatable.new(params, users: users, context: view_context, admin: current_user.admin?) get it back like that:

def current_user_admin?
    options[:admin]
end

but how can I use this boolean to hide or show an entire column please ? I've also found this but not sure it's implemented in the gem

n-rodriguez commented 2 years ago

but how can I use this boolean to hide or show an entire column please ? I've also found this but not sure it's implemented in the gem

This is how to do :) It belongs to the "view" side of DataTables. The gem's role is only to generate JSON data that will be treated by DataTables.