Giter VIP home page Giter VIP logo

Comments (12)

at-the-vr avatar at-the-vr commented on July 17, 2024

I missed to mention, the way I have written the logRow method right inside that button, that method is not getting triggered and I would just like to know if there's an approach to do that (Thanks again for hearing me)

from vue3-table-lite.

linmasahiro avatar linmasahiro commented on July 17, 2024

Hi, @at-the-vr
Here have 2 solution.

Solution 1:

  1. Add is-rows-el to your button's class, and remove the @click="logRow(row)".
  2. Add below code to @is-finished event. example
      Array.prototype.forEach.call(elements, function (element) {
        if (element.classList.contains("common-button")) {
          element.addEventListener("click", function (event) {
            event.stopPropagation(); // prevents further propagation of the current event in the capturing and bubbling phases.
            console.log(this.dataset.id);
          });
        }
      });

Solution 2:
Use v-slot mode. You can ref example

from vue3-table-lite.

linmasahiro avatar linmasahiro commented on July 17, 2024

Hi, @at-the-vr
If you want use options api to implement v-slot mode, here you are.

<template>
  <table-lite
    :is-slot-mode="true"
    :is-loading="table.isLoading"
    :columns="table.columns"
    :rows="table.rows"
    :total="table.totalRecordCount"
    :sortable="table.sortable"
    @do-search="doSearch"
    @is-finished="table.isLoading = false"
  >
    <template v-slot:name="data">
      <button @click="logRow(data.value)">{{ data.value.name }}</button>
    </template>
  </table-lite>
</template>

<script>
import TableLite from "vue3-table-lite";

// Fake Data for 'asc' sortable
const sampleData1 = (offst, limit) => {
  offst = offst + 1;
  let data = [];
  for (let i = offst; i <= limit; i++) {
    data.push({
      id: i,
      name: "TEST" + i,
      email: "test" + i + "@example.com",
    });
  }
  return data;
};

// Fake Data for 'desc' sortable
const sampleData2 = (offst, limit) => {
  let data = [];
  for (let i = limit; i > offst; i--) {
    data.push({
      id: i,
      name: "TEST" + i,
      email: "test" + i + "@example.com",
    });
  }
  return data;
};

export default {
  name: "vue-scheduler-lite",
  components: { TableLite },
  props: {},
  data() {
    return {
      table: {
      isLoading: false,
        columns: [
          {
            label: "ID",
            field: "id",
            width: "3%",
            sortable: true,
            isKey: true,
          },
          {
            label: "Name",
            field: "name",
            width: "10%",
            sortable: true,
          },
          {
            label: "Email",
            field: "email",
            width: "15%",
            sortable: true,
          },
        ],
        rows: [],
        totalRecordCount: 0,
        sortable: {
          order: "id",
          sort: "asc",
        },
      }
    };
  },
  created() {
    this.doSearch(0, 10, "id", "asc");
  },
  methods: {
    doSearch(offset, limit, order, sort) {
      this.table.isLoading = true;
      setTimeout(() => {
        this.table.isReSearch = offset == undefined ? true : false;
        if (offset >= 10 || limit >= 20) {
          limit = 20;
        }
        if (sort == "asc") {
          this.table.rows = sampleData1(offset, limit);
        } else {
          this.table.rows = sampleData2(offset, limit);
        }
        this.table.totalRecordCount = 20;
        this.table.sortable.order = order;
        this.table.sortable.sort = sort;
      }, 600);
    },
    logRow(row) {
      console.log(row);
    }
  }
};
</script>

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

Yeah that's what i did also my side, one thing, when i switch to v-slot mode, it broke the whole sorting process ( I am not using the do-search method)
now With static mode the sorting process is pretty smooth but i dont understand what is missing in v-slot mode

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

https://stackblitz.com/edit/vue-lwupnc?file=src/App.vue , can I ask if you can try running this app on stackblitz ? with following dependencies

image

from vue3-table-lite.

linmasahiro avatar linmasahiro commented on July 17, 2024

https://stackblitz.com/edit/vue-lwupnc?file=src/App.vue , can I ask if you can try running this app on stackblitz ? with following dependencies image

Your example is crash now, so I don't know why not working.
Maybe you can implement a simple sample your self first?

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

I am sorry you meant crash as in ? like stackblitz won't load on your desktop or the application is wrong giving errors in console (currently I tried on incognito and the application loaded just fine)

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

https://stackblitz.com/edit/vue-lwupnc?file=src/App.vue , can I ask if you can try running this app on stackblitz ? with following dependencies image

Your example is crash now, so I don't know why not working. Maybe you can implement a simple sample your self first?

I have trimmed couple of markdown and css to reduce the overall length, can you give this another try ?

from vue3-table-lite.

linmasahiro avatar linmasahiro commented on July 17, 2024

I have trimmed couple of markdown and css to reduce the overall length, can you give this another try ?

OK, it's working now.
I saw your example and found the bug.
You need add :is-static-mode="true" to <table-lite>, because you not use do-search to get any data, that call static mode in vue3-table-lite. Please refs Here and Here about do-search

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

image

Is this a bad way to produce my results (they are kinda working)

from vue3-table-lite.

linmasahiro avatar linmasahiro commented on July 17, 2024

if resolved, I will be close this issue :)

from vue3-table-lite.

at-the-vr avatar at-the-vr commented on July 17, 2024

I guess yeah, thanks for the slot stuff

from vue3-table-lite.

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.