Hi,
I am using TypeScript and I am trying to display a grid in which three columns would be text and one column would be and image. How can insert a template for the fourth cell being and HTML image in each row? JSX is not enabled in my project so I need to come up with a solution using slots and props. I am using kendo-vue-grid and not the wrapper. My Grid.vue looks like this:
<template>
<grid :data-items="imagesData.images" :columns="columns"></grid>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Grid, type GridCellProps, type GridColumnProps } from '@progress/kendo-vue-grid';
const customImageCell = (props: GridCellProps) => {
return `<img src = "${props.dataItem}" alt="thumnailUrl" ></img>` //if I log props.dataItem, its undefined
}
const columns = ref([
{ field: 'name', title: 'Name' },
{ field: 'category', title: 'Category' },
{ field: 'artist', title: 'Artist' },
{ field: 'price', title: 'Price' },
{ title: 'Thumbnail', cell: (props: GridCellProps) => customImageCell(props) },
] as GridColumnProps[]);
</script>
My data looks like this
{
"images": [
{
"id": 1,
"name": "Multicolor Abstract",
"category": "Abstract Art",
"artist": "Artist 1",
"price": 795.95,
"numberSold": "567",
"thumbnail": "/images/Abstract/AbstractArt1.jfif"
},
{
"id": 2,
"name": "Coral colors",
"category": "Oil painting",
"artist": "Artist 2",
"price": 795.95,
"numberSold": "567",
"thumbnail": "/images/OilPaintings/AbstractOilPainting.jpeg"
},
{
"id": 3,
"name": "Forest",
"category": "Landscape",
"artist": "Artist 1",
"price": 795.95,
"numberSold": "567",
"thumbnail": "/images/Landscape/ForestLandscape.jpg"
}
}
Grid renders but the Thumbnail column just prints <img src = "undefined" alt="thumnailUrl" ></img> as text.
I have verified that my data is available by printing it in console.log.
Help would be appreciated.
Thanks,
Hiba