Comments (4)
Hi, @mambari
If you want to filter data on client, you should be use static-mode.
I fixed your code on here, and it good work.
<template>
<div class="contentAccountsTab">
<vue-table-lite
:is-static-mode="true"
:has-checkbox="true"
:is-loading="table.isLoading"
:columns="table.columns"
:rows="table.rows"
:total="table.totalRecordCount"
:sortable="table.sortable"
:messages="table.messages"
@is-finished="tableLoadingFinish"
@return-checked-rows="updateCheckedRows"
/>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, computed } from "vue";
import VueTableLite from "vue3-table-lite";
// import { useAuth } from "@/composable/auth";
// Define row data interface
interface rowData {
id?: number;
name: string;
email: string;
role?: string;
}
export default defineComponent({
name: "AccountsTab",
components: { VueTableLite },
setup() {
// const {
// listUsers,
// } = useAuth();
// Init Your table settings
const table = reactive({
isLoading: false,
columns: [
{
label: "ID",
field: "id",
width: "3%",
sortable: true,
isKey: true,
},
{
label: "Email",
field: "email",
width: "15%",
sortable: true,
},
{
label: "Role",
field: "role",
width: "10%",
sortable: true,
},
{
label: "Action",
field: "quick",
width: "3%",
display(row: rowData) {
return `<button type="button" data-id="${row.id}" data-email="${row.email}" class="is-rows-el remove-btn">Supprimer</button>`;
},
},
],
rows: [] as Array<rowData>,
totalRecordCount: computed((): number => {
return table.rows.length;
}),
sortable: {
order: "id",
sort: "asc",
},
messages: {
pagingInfo: "Showing {0}-{1} of {2}",
pageSizeChangeLabel: "Row count:",
gotoPageLabel: "Go to page:",
noDataAvailable: "No data",
},
});
/**
* lis all users
*/
const listAllUsers = async () => {
table.isLoading = true;
const data: rowData[] = [];
for (let i = 0; i < 126; i++) {
data.push({
id: i,
name: "TEST" + i,
email: "test" + i + "@example.com",
role: "ADMIN",
});
}
// To Mehdi: restore your source plz.
// const list = JSON.parse(await listUsers());
// const offst = 0;
// const limit = list.users.length;
// for (let i = offst; i < limit; i += 1) {
// data.push({
// id: i,
// name: `USER ${i}`,
// email: `${list.users[i].email}`,
// role: `${list.users[i].role}`,
// });
// }
table.rows = data;
};
/**
* Table search finished event
*/
const tableLoadingFinish = (elements: Array<HTMLElement>) => {
console.log("elem = ", elements);
table.isLoading = false;
Array.prototype.forEach.call(elements, function (element: HTMLElement) {
if (element.classList.contains("remove-btn")) {
element.addEventListener("click", function () {
console.log(`${this.dataset.id} name-btn click!!`);
});
}
});
};
/**
* Row checked event
*/
const updateCheckedRows = (rowsKey: number) => {
console.log("rowsKey = ", rowsKey);
};
listAllUsers();
return {
table,
tableLoadingFinish,
updateCheckedRows,
};
},
});
</script>
※ You can reference Filter example or Asynchronous filter example to helpful you.
from vue3-table-lite.
Hi, thank you for your help 🙏 .
I copy past your solution but I get that (stuck with loading):
(But I am with "vue3-table-lite": "^1.0.7" )
from vue3-table-lite.
Hi, @mambari
Hi, thank you for your help 🙏 . I copy past your solution but I get that (stuck with loading): (But I am with "vue3-table-lite": "^1.0.7" )
Has a tableLoadingFinish method not working on static-mode
bug on version 1.0.7, fixed on v1.0.8.
So upgrade to upper v1.0.8, thanks.
from vue3-table-lite.
Thank you so much. I updated and It works like a charm.
from vue3-table-lite.
Related Issues (20)
- 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
- [OTHERS] Call a Function inside of display property for a button HOT 12
- 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
- Page selection list too long HOT 1
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.