DrkStr
DrkStr

Reputation: 1932

Styling a md-grid-list

I am using an Angular Material grid list to display around 500 - 1000 items. I am having some trouble styling it to my liking. Here is what the grid list looks like now:

<md-grid-list md-cols-xs="1" md-cols-sm="2" md-cols-md="4" md-cols-gt-md="6"
              md-row-height="16:9"
              md-gutter="12px" md-gutter-gt-sm="8px">

  <md-grid-tile ng-repeat="orgOrder in vm.orgOrders | filter: query1"
                style="background: #f5f5f5"
                layout-align="center center"
                ng-click="vm.addOrder(orgOrder)">
    <div layout="column">
      <div> {{orgOrder.orderNumber}}</div>
      <!--<div> {{orgOrder.reqExFact | date : 'dd/MM/yyyy'}}</div>-->
    </div>

  </md-grid-tile>
</md-grid-list>

my awesome grid list

Here is what I would like to do:

  1. My grid titles(items) are a way too big for a single line, how do I make my grid titles fit the data in them? Setting the md-row-height="fit" makes it look like this. enter image description here
  2. At the moment my grid-list is several 'scrolls' long. I would like to put it into a container and add a scroll to it. Warping my grid-list or grid title in an md-container sets their height to 0.

Let me know if you need to see any more of my code.

here is a jsfiddle similar to my code:https://jsfiddle.net/rakshak/6tjgbb85/

I would like the grid titles(items) to fit the text in them and I would like to wrap a container around the entire grid list and have a overflow scroll bar instead of the entire window scrolling.

Upvotes: 4

Views: 3807

Answers (1)

Mike Feltman
Mike Feltman

Reputation: 5176

Setting md-row-height like md-row-height="20px" or md-row-height="30px" seems to address the height issues nicely. Nesting the grid inside of a fixed height div defined something like this:

.tileContainer {display:block;
    width:100%;
    height:100px;}

will give you a scroll bar for the tiles.

I forked your plunker here: https://jsfiddle.net/uegLh6t4/

Upvotes: 1

Related Questions