2
votes

Users have many different preferences for the columns that are shown for the same DataObject in the same ModelAdmin and would like to control them for their own sessions.

Given the following dataobject...

class MyDataObject extends DataObject {
    static $db = array(
        'Name'      => 'Varchar',
        'Date'      => 'SS_DateTime',
        'Number'    => 'Decimal(8,2)',
    );
    public static $summary_fields = array(
        'Name',
        'Date',
        'Number'
    );
}

...and the following ModelAdmin...

class MyModelAdmin extends ModelAdmin {
    static $mangaged_models = array(
    'MyDataObject',
    );  
    static $url_segment = 'mymodeladmin';
    static $menu_title = 'MyModelAdmin';
    static $menu_priority = 9;
}

...is there a straightforward javascript only solution (that I imagine would store the columns chosen in a cookie) or something more programmatic (i.e. php) that would control the columns on a per user basis - allowing each user to select the columns they want and it remembers it from session to session?

Any help is much appreciated.

1
I have never heard about existing module with such functionality, but I would implement one to hide existing columns and store configuration in the browser localStorage.Greg Smirnov
csy_dot_io that is perfect - if you want to put that as an answer - I'd accept it right awayBarry
@Barry thanks and done ;)csy_dot_io

1 Answers

3
votes

Like mentioned in the comments, you could have a look at this module, which should provide you with the functionality you'll need.

https://github.com/smindel/silverstripe-GridFieldAddOns/blob/master/docs/en/GridFieldUserColumns.md

From the docs:

Just add the following code to the end of your mysite/_config.php

Member::add_extension('GridFieldUserColumnsExtension');
Object::useCustomClass('GridFieldConfig_RecordEditor', 'GridFieldConfig_ExtendedRecordEditor');
Object::useCustomClass('GridFieldConfig_RelationEditor', 'GridFieldConfig_ExtendedRelationEditor');

Screenshot of the column selector