0

guys I need to display an image into the field of Datatable I've tried everything but nothing works,

at that moment my code is:

<q-table
    :data="driverTable.data"
    :columns="driverTable.columns"
    row-key="objectId"
  >
    <template v-slot:no-data="{ icon, message, filter }">
      <div class="full-width row flex-center q-gutter-sm">
        <q-icon size="2em" name="sentiment_dissatisfied" />
        <span>{{ message }}</span>
        <q-icon size="2em" :name="filter ? 'filter_b_and_w' : icon" />
      </div>
    </template>

    <template v-slot:top="props">
      <q-btn flat round dense
        @click="props.toggleFullscreen" color="grey-8" class="q-ml-md"
        :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
        :v-bind="props.inFullscreen"
        :title="props.inFullscreen ? 'Minimiser' : 'Plain ecran'"
      />
    </template>
  </q-table>

and my js code:

data () {
    return {
      driverTable: {
        columns: [
          {
            name: 'objectId',
            field: row => row.objectId,
            format: val => ''
          },
          {
            name: 'name',
            label: 'Nom complete',
            align: 'left',
            field: row => row.name,
            format: val => `${val}`,
            sortable: true,
            classes: 'ellipsis'
          },
          {
            name: 'carPermit',
            required: true,
            label: 'Permit',
            field: row => row.carPermit, //
            align: 'center',
            format: val => `${'<img height="75%" width="75%" src="' + val + '"/>'}`
          }
        ],
        data: []
      }
    }
  }

I've tried <img> into field format and bild on it the url source but it gives me just the balise on stiring format

1 Answer 1

1

please follow this

<q-table
        :data="driverTable.data"
        :columns="driverTable.columns"
        row-key="objectId"
    >
        <template v-slot:no-data="{ icon, message, filter }">
            <div class="full-width row flex-center q-gutter-sm">
                <q-icon size="2em" name="sentiment_dissatisfied" />
                <span>{{ message }}</span>
                <q-icon size="2em" :name="filter ? 'filter_b_and_w' : icon" />
            </div>
        </template>

        <template v-slot:top="props">
            <q-btn flat round dense
                   @click="props.toggleFullscreen" color="grey-8" class="q-ml-md"
                   :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
                   :v-bind="props.inFullscreen"
                   :title="props.inFullscreen ? 'Minimiser' : 'Plain ecran'"
            />
        </template>
        <template v-slot:body-cell-carPermit="props">
            <q-avatar>
                <img :src="props.row.carPermit">
            </q-avatar>
        </template>


    </q-table>

and remove format and field keys from cardPermit

data () {
return {
  driverTable: {
    columns: [
      {
        name: 'objectId',
        field: row => row.objectId,
        format: val => ''
      },
      {
        name: 'name',
        label: 'Nom complete',
        align: 'left',
        field: row => row.name,
        format: val => `${val}`,
        sortable: true,
        classes: 'ellipsis'
      },
      {
        name: 'carPermit',
        required: true,
        label: 'Permit',
        align: 'center',
      }
    ],
    data: []
  }
}

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.