Laureant
Laureant

Reputation: 1019

Multiple columns with different widths in Ionic item row

I want to have an Ionic list with 3(or 4, see below) columns:

I tried the following thing:

<ion-list class="plan-list">
  <ion-item  class="plan" text-wrap detail-push *ngFor="let item of items">
    <ion-grid>
      <ion-row>
        <ion-col col-2 class="plan-left" style="border-right:2px solid #A6A6A6">
              //tappable icon which has a fixed size, and should always be centered both vertically and horizontally in it's place
        </ion-col>

        <ion-col col-7 class="plan-right">
          <div class="plan-name">{{item.Name}}</div>
        </ion-col>
        <ion-col col-1 class="plan-right">
          <div>
            <img class="plan-image-icon" src="icons/documentIcon.png" width="20px"/>
          </div>
        </ion-col>
      </ion-row>
    </ion-grid>
  </ion-item>

I tried to use the col-x modifiers for column width, but I need to be able to fine-tune them a little bit more.

Here's a picture of how I want it to look: enter image description here

I am unsure if I can put ion-grid inside an ion-item tag, but I've found some random examples online. Please let me know how should I continue with this setup.

I want to have a responsive design, the Green part where the text goes should change it's width according to the screen width, if that's possible.

Upvotes: 2

Views: 7079

Answers (1)

Manel Alonso
Manel Alonso

Reputation: 397

The setup is right.

The thing is that on your grid you are setting 10 columns instead of 12. This should work:

<ion-list class="plan-list">
  <ion-item  class="plan" text-wrap detail-push *ngFor="let item of items">
    <ion-grid>
      <ion-row>
        <ion-col col-2 class="plan-left" style="border-right:2px solid #A6A6A6">
              //tappable icon which has a fixed size, and should always be centered both vertically and horizontally in it's place
        </ion-col>

        <ion-col col-9 class="plan-right">
          <div class="plan-name">{{item.Name}}</div>
        </ion-col>
        <ion-col col-1 class="plan-right">
          <div>
            <img class="plan-image-icon" src="icons/documentIcon.png" width="20px"/>
          </div>
        </ion-col>
      </ion-row>
    </ion-grid>
  </ion-item>

Also i noticed that you are missing a column with the chevron. Might try to add it?

Upvotes: 2

Related Questions