Comments (5)
@Nyantekyi I'll keep this in mind when building the Table
component for v3
😊
from ui.
I'm also looking for a way to manipulate the header because I would like to display icons there
from ui.
I'm also looking for a way to manipulate the header because I would like to display icons there
@migro1982 you can do something like this.
It's not as obvious as proposed in the issue, but it solves the problem.
<template
v-for="header in headers"
:key="header.key"
#[`${header.key}-header`]="{ column }"
>
Slot of "{{ column }}"
</template>
from ui.
This would be so helpful... this is my current set up
<script setup lang="ts">
import { z } from "zod";
import type { FormError, FormSubmitEvent } from "#ui/types";
const formtype = z.object({
name: z.string(),
title: z.string(),
email: z.string().email(),
role: z.string(),
});
const datatype = z.object({
id: z.number(),
name: z.string(),
title: z.string(),
email: z.string().email(),
role: z.string(),
});
type dataschema = z.output<typeof datatype>;
const people = reactive<dataschema[]>([
{
id: 1,
name: "Lindsay Walton",
title: "Front-end Developer",
email: "[email protected]",
role: "Member",
},
{
id: 2,
name: "Courtney Henry",
title: "Designer",
email: "[email protected]",
role: "Admin",
},
{
id: 3,
name: "Tom Cook",
title: "Director of Product",
email: "[email protected]",
role: "Member",
},
{
id: 4,
name: "Whitney Francis",
title: "Copywriter",
email: "[email protected]",
role: "Admin",
},
{
id: 5,
name: "Leonard Krasner",
title: "Senior Designer",
email: "[email protected]",
role: "Owner",
},
]);
const edit = ref<boolean>(false);
const editIndex = ref<number>();
function select(row: dataschema) {
edit.value = true;
editIndex.value = row.id;
}
// const selected = ref([people[1]]);
</script>
<template>
<UTable :rows="people" @select="select">
<template #name-data="{ row }">
<div class="flex items-center">
<!-- Create a uinput that only shows when editindex is row.id else show row content -->
<UInput v-if="editIndex === row.id" v-model="row.name" :state="row.name" />
<span v-else>{{ row.name }}</span>
</div>
</template>
<template #title-data="{ row }">
<div class="flex items-center">
<UInput v-if="editIndex === row.id" v-model="row.title" :state="row.title" />
<span v-else>{{ row.title }}</span>
</div>
</template>
<template #email-data="{ row }">
<div class="flex items-center">
<UForm :schema="datatype" :state="row">
<UFormGroup name="email">
<UInput v-if="editIndex === row.id" v-model="row.email" />
<span v-else>{{ row.email }}</span>
</UFormGroup>
</UForm>
<!-- <UInput v-if="editIndex === row.id" v-model="row.email" :state="row.email" /> -->
</div>
</template>
<template #role-data="{ row }">
<div class="flex items-center">
<USelect
v-if="editIndex === row.id"
v-model="row.role"
:state="row.role"
:options="[
{ value: 'Admin', label: 'Admin' },
{ value: 'Member', label: 'Member' },
{ value: 'Owner', label: 'Owner' },
]"
/>
<span v-else>{{ row.role }}</span>
</div>
</template>
</UTable>
</template>
I would really prefer it if I could indicate a condition for when the row is selected and present the complete form with validation else default to the table data... This is my implementation of utable with form input
from ui.
@benjamincanac
An I deal situation for me is something similar to what primevue did here
https://tailwind.primevue.org/datatable/#cell_edit
from ui.
Related Issues (20)
- Using UCheckbox with v-for breaks partial functionality HOT 2
- Add file upload component HOT 2
- When a Popover component is nested inside a Popover component, clicking the trigger element can open it, but clicking the trigger element again cannot close it. You need to click the outer element to close it. HOT 1
- Theming White Color Globally
- Is there any way to remove the textarea autoresize shift?
- InputMenu: monitor the popper size HOT 3
- Links not works in next prev arrows UPagination HOT 1
- Skeleton: as property HOT 1
- UForm: apply transformations from the validator
- Help slots for Checkbox, Radio and RadioGroup
- Can't adding Notification in composable HOT 2
- Notification description has zero margin top when title is specified
- How to pass ui props to UCard? HOT 2
- FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory HOT 1
- Accordion `items` type does not allow custom content HOT 1
- Setting color prop dynamically causes issues HOT 3
- after build “Cannot find module shiki” I use the template of "https://github.com/nuxt-ui-pro/saas.git" in Nuxt UI Pro HOT 2
- Strip all dark mode classes
- [Edge] SelectMenu: returns no results when using lazy search with custom #option slot HOT 1
- Add "to" and "href" props to Avatar component HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui.