How to customize list of columns on the view page?

21 views
Skip to first unread message

Georgiy Avakyan

unread,
Jul 14, 2015, 10:12:16 AM7/14/15
to actives...@googlegroups.com
Hi there!
I have an scaffold with big number of columns (50+). I want to give user ability to select which columns he wants to see on page.
I have two ideas how to implement this, but I don't know how to do it.
1) Button 'select columns' at the top of collectionwith list of columns and checkboxes on the left. Check the boxes -> click apply and you can see columns which you want.
2) Simple, 'dumb' way: Just create second web page with another set of columns (e.g. page_part1 with columns from 1 to 25 and page_part2 with columns from 26 to 50)

In 1) case I just don't have an idea how to do it. In 2) case I don't know how to implement 2 different views for one controller. May be there's way to just set two kind of activescaffold config in controller and then show config_1 for admin and config_2 for user? Any another ideas?

Sergio Cambra

unread,
Jul 14, 2015, 10:34:03 AM7/14/15
to actives...@googlegroups.com, Georgiy Avakyan

You can use active_scaffold_config_list

 

http://github.com/activescaffold/active_scaffold_config_list

Georgiy Avakyan

unread,
Jul 14, 2015, 10:50:04 AM7/14/15
to actives...@googlegroups.com
Thank you! Is this gem compatible with rails 4? I'm using rails -v 4.1.10. I will test in in couple of hours and write an answer from my side.

Georgiy Avakyan

unread,
Jul 14, 2015, 11:10:38 AM7/14/15
to actives...@googlegroups.com
Okay, this gem works well! I'm sorry, but I forgot to say, that I need select columns which I want to view and edit. If I select item to view, I see only selected columns, all is ok, but when I want to create new record here opens window with all columns as in my controller conf.columns = [..] set. Can this be realized to?

Sergio Cambra

unread,
Jul 14, 2015, 11:19:26 AM7/14/15
to actives...@googlegroups.com, Georgiy Avakyan

It's not supported by this gem, is only config_list.

 

You could try adding a before_filter for :new, :create, :edit, :update, and set conf.create.columns or conf.update.columns from list_columns method.

 

El Martes, 14 de julio de 2015 08:10:38 Georgiy Avakyan escribió:

> Okay, this gem works well! I'm sorry, but I forgot to say, that I need

> select columns which I want to view *and edit. *If I select item to view, I

Georgiy Avakyan

unread,
Jul 14, 2015, 11:25:45 AM7/14/15
to actives...@googlegroups.com
Thanks for your help! I will try this method tomorrow and write here what I will get.
Reply all
Reply to author
Forward
0 new messages