I am working on a project to develop a custom and versatile datatable component. My goal is to be able to adjust the appearance of the datatable on each page, while maintaining consistent functionality. I want to pass data rows into the component and have the flexibility to customize the layout accordingly. However, I am struggling to figure out how to achieve this. Here's an illustration of my dilemma:
For instance, one page may require this template:
<datatable>
<div v-for="row in rows" class="header" @click="sortBy(row.field)">row.title</div>
<div v-for="row in rows">row.value</div>
</datatable>
While another page demands a different layout:
<datatable>
<h1>
<span v-for="row in rows" @click="sortBy(row.field)">row.title</span>
</h1>
<h3 v-for="row in rows">row.value</h3>
</datatable>
I am grappling with a solution to integrate the sortBy function inside the component. Is there a way to make this work seamlessly?