Code: Select all
<Column header="Country" filterField="country.name" filterMatchMode="contains">
<template #body="slotProps">
<span class="p-column-title">Country</span>
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
<span class="image-text">{{slotProps.data.country.name}}</span>
</template>
<template #filter>
<InputText type="text" v-model="filters['country.name']" class="p-column-filter" placeholder="Search by country"/>
</template>
</Column>
This error of course happens after modifying the template body to account for country being null, but it is not possible to do that with the filter since all you're able to do is specify the field name, and not give any conditions of what to do if the field is null.TypeError: Cannot read property 'name' of null
Is there any way to mitigate this issue?