Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Gridfield column behaviour in list view

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1068 Views
  • tmkp
    Avatar
    Community Member
    42 Posts

    Gridfield column behaviour in list view Link to this post

    Hi again,
    is there any way yet to control column width in the gridfield list view?

    Again following this example, using long text in the Description field of a contact will result in a very very wide column with all of the text in one line and no line breaks.

    Also, the Main Content and Contacts tabs + the Add New button are being moved outside of the visible area to the far right of the scrolling pane.

    I've already filed a ticket a couple days ago which is here, but no response so far.

    Version is 3.0 stable, issue occurs with sortable grid field both active and deactivated.

    Any ideas?

    Thanks in advance,
    Andi

    Attached Files
  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Gridfield column behaviour in list view Link to this post

    I suppose, while there is no 'official solution' yet, you could try and use css styles to limit the width of a column. By default every colum's td gets a class 'col-fieldname' added to it.

    you could try setting a CustomCSS requirement for it. Say, from within the getCMSFields() function or, in ModelAdmin, from your admin class init()...

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Gridfield column behaviour in list view Link to this post

    Just adding width rules to the columns doesn't work, as for some reason there's a "whitespace:no-wrap" rule added to every table cell by default, resulting in columns stretching endlessly.

    Came up with this workaround. It's not pretty but it should do for the time being:

    mysite/css/contacts-admin.css

    table.ss-gridfield-table td {
       white-space:normal !important;
    }

    table.ss-gridfield-table td.col-Thumbnail {
       width:15% !important;
    }

    table.ss-gridfield-table td.col-Name {
       width:15% !important;
    }

    table.ss-gridfield-table td.col-Description {
       width:40% !important;
    }

    table.ss-gridfield-table td.col-Website {
       width:22% !important;
    }

    ContactListPage.php

    // Create Grid Field
    public function getCMSFields() {
       Requirements::css("mysite/css/contacts-admin.css");
       ...
    }

    Now the only remaining issue is that the Description text is one single blob of text, stripped of all paragraphs/linebreaks. Custom getters again don't seem to be working on this one. I'll keep digging.

    Thanks martimiz!

  • jak
    Avatar
    Community Member
    46 Posts

    Re: Gridfield column behaviour in list view Link to this post


    Now the only remaining issue is that the Description text is one single blob of text, stripped of all paragraphs/linebreaks. Custom getters again don't seem to be working on this one. I'll keep digging.

    This is currently broken, see http://open.silverstripe.org/ticket/7590. I posted a workaround in http://www.silverstripe.org/general-questions/show/20136

    HTH
    Jak

  • Graphicator
    Avatar
    Community Member
    62 Posts

    Re: Gridfield column behaviour in list view Link to this post

    For my purposes, I just had to comment out the white-space rule on GridField.css, but I only checked it in one browser.

    I was getting a long single line that didn't wrap, and this fixed the stretched out column look.

    .cms table.ss-gridfield-table tbody td {
    /* white-space: nowrap; */
    width: auto;
    }

    I'd like to know when the width is controlled soon.

    1068 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.