Giter VIP home page Giter VIP logo

Comments (5)

benjamincanac avatar benjamincanac commented on July 18, 2024 2

@Nyantekyi I'll keep this in mind when building the Table component for v3 😊

from ui.

migro1982 avatar migro1982 commented on July 18, 2024

I'm also looking for a way to manipulate the header because I would like to display icons there

from ui.

caiotarifa avatar caiotarifa commented on July 18, 2024

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.

Nyantekyi avatar Nyantekyi commented on July 18, 2024

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.

Nyantekyi avatar Nyantekyi commented on July 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.