import { h, defineComponent, computed } from "vue" import { useVueTable, createColumnHelper, getCoreRowModel, FlexRender, } from "@tanstack/vue-table" type Order={ id:number; status:string; amount:number } const StatusBadge=defineComponent({ props:{ status:String }, setup(props){ const colour=computed(()=>({ paid:"bg-green-100 text-green-800", pending:"bg-yellow-100 text-yellow-800", cancelled:"bg-red-100 text-red-800", }[props.status??"pending"]??"bg-gray-100")) return ()=>h("span",{class:colour.value},props.status) }, }) const ch=createColumnHelper() const columns=[ ch.accessor("status",{ header:"Status", cell: info=>h(StatusBadge,{status:info.getValue()}), }), ch.accessor("amount",{ header:"Amount", cell: info=>`$${info.getValue().toFixed(2)}`, }), ch.display({ id:"actions", header:"Actions", cell: ({row})=>h("div",null,[ h("button",{onClick:()=>editOrder(row.original)},"Edit"), h("button",{onClick:()=>deleteOrder(row.original.id)},"Delete"), ]), }), ] ">
import { h, defineComponent, computed } from "vue" import { useVueTable, createColumnHelper, getCoreRowModel, FlexRender, } from "@tanstack/vue-table" type Order={ id:number; status:string; amount:number } const StatusBadge=defineComponent({ props:{ status:String }, setup(props){ const colour=computed(()=>({ paid:"bg-green-100 text-green-800", pending:"bg-yellow-100 text-yellow-800", cancelled:"bg-red-100 text-red-800", }[props.status??"pending"]??"bg-gray-100")) return ()=>h("span",{class:colour.value},props.status) }, }) const ch=createColumnHelper() const columns=[ ch.accessor("status",{ header:"Status", cell: info=>h(StatusBadge,{status:info.getValue()}), }), ch.accessor("amount",{ header:"Amount", cell: info=>`$${info.getValue().toFixed(2)}`, }), ch.display({ id:"actions", header:"Actions", cell: ({row})=>h("div",null,[ h("button",{onClick:()=>editOrder(row.original)},"Edit"), h("button",{onClick:()=>deleteOrder(row.original.id)},"Delete"), ]), }), ] " />
import { h, defineComponent, computed } from \"vue\" import { useVueTable, createColumnHelper, getCoreRowModel, FlexRender, } from \"@tanstack/vue-table\" type Order={ id:number; status:string; amount:number } const StatusBadge=defineComponent({ props:{ status:String }, setup(props){ const colour=computed(()=>({ paid:\"bg-green-100 text-green-800\", pending:\"bg-yellow-100 text-yellow-800\", cancelled:\"bg-red-100 text-red-800\", }[props.status??\"pending\"]??\"bg-gray-100\")) return ()=>h(\"span\",{class:colour.value},props.status) }, }) const ch=createColumnHelper() const columns=[ ch.accessor(\"status\",{ header:\"Status\", cell: info=>h(StatusBadge,{status:info.getValue()}), }), ch.accessor(\"amount\",{ header:\"Amount\", cell: info=>`$${info.getValue().toFixed(2)}`, }), ch.display({ id:\"actions\", header:\"Actions\", cell: ({row})=>h(\"div\",null,[ h(\"button\",{onClick:()=>editOrder(row.original)},\"Edit\"), h(\"button\",{onClick:()=>deleteOrder(row.original.id)},\"Delete\"), ]), }), ] " />
«
Prev
»
Next
Web / TanStack Interview Questions
Angular Interview questions (124)
ReactJS Interview questions (64)
Typescript interview questions (22)
NodeJS Interview questions (14)
Nativescript interview questions (5)
React native Interview questions (51)
ES6 Interview questions (7)
ES8 Interview questions (3)
RxJs Interview questions (17)
HTML Interview questions (9)
JSP interview questions (6)
TanStack Interview Questions (38)
How do you render custom Vue components inside TanStack Table cells?
The cell column definition accepts a function returning a string, VNode, or component. FlexRender handles all three transparently so you never need conditional render logic.
<script setup lang="ts">
import { h, defineComponent, computed } from "vue"
import {
useVueTable, createColumnHelper, getCoreRowModel, FlexRender,
} from "@tanstack/vue-table"
type Order={ id:number; status:string; amount:number }
const StatusBadge=defineComponent({
props:{ status:String },
setup(props){
const colour=computed(()=>({
paid:"bg-green-100 text-green-800",
pending:"bg-yellow-100 text-yellow-800",
cancelled:"bg-red-100 text-red-800",
}[props.status??"pending"]??"bg-gray-100"))
return ()=>h("span",{class:colour.value},props.status)
},
})
const ch=createColumnHelper<Order>()
const columns=[
ch.accessor("status",{
header:"Status",
cell: info=>h(StatusBadge,{status:info.getValue()}),
}),
ch.accessor("amount",{
header:"Amount",
cell: info=>`$${info.getValue().toFixed(2)}`,
}),
ch.display({
id:"actions",
header:"Actions",
cell: ({row})=>h("div",null,[
h("button",{onClick:()=>editOrder(row.original)},"Edit"),
h("button",{onClick:()=>deleteOrder(row.original.id)},"Delete"),
]),
}),
]
</script>
Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Earn passively and while sleeping
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull ! Receive free stock by signing up using the link: Webull signup .
More Related questions...
Comments & Discussions
Please enable JavaScript to view the comments powered by Disqus.