Comments (12)
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.
Hi, @at-the-vr
Here have 2 solution.
Solution 1:
- Add
is-rows-el
to your button's class, and remove the@click="logRow(row)"
. - 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.
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.
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.
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
from vue3-table-lite.
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
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.
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.
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
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.
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.
Is this a bad way to produce my results (they are kinda working)
from vue3-table-lite.
if resolved, I will be close this issue :)
from vue3-table-lite.
I guess yeah, thanks for the slot stuff
from vue3-table-lite.
Related Issues (20)
- Multiple fixed columns HOT 3
- Header's first column is always fixed on horizontal scrolling
- Unable to get table width to be responsive and fixed first column in table header not fixed HOT 18
- Sortable function doesn't work with grouping key HOT 2
- Links under slot mode stopped working in 1.3.2 HOT 1
- checking rows doesn't work in 1.3.2 and 1.3.3 HOT 1
- Return duplicated value on「return-checked-rows」event HOT 1
- click event not handled in tableLoadingFinish function HOT 2
- Static mode pagination not working as expected HOT 3
- Is it possible to add 'return clearChecked' if 'hasCheckbox'?
- Is it possible to add 'return clearChecked' if 'hasCheckbox'? HOT 6
- Bug when dynamically showing checkboxes HOT 1
- Grouping with toggle like a treeview inside table ? HOT 4
- Unchecking row returns old value HOT 5
- Examples not compatible with latest version of vue3 and node18 HOT 1
- Allow HTML in header HOT 4
- Vertical highlighting on mouse hover HOT 3
- has-checkbox and is-fixed-first-column turned on, only checkbox header stays when table scrolls horizontally. HOT 3
- checked items not being cleared HOT 6
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 vue3-table-lite.