Comments (10)
Hi, @mambari
I rewrite my document. Hope helpful for you.
https://linmasahiro.github.io/vue3-table-lite/dist/
from vue3-table-lite.
const tableLoadingFinish = function loadingFinish(elements) {
Fix this row to
const tableLoadingFinish = (elements) => {
from vue3-table-lite.
I did but still, nothing is happening.
Sorry I am not good enough to get why it's happening.
Thank you for your help. If I succeed to make it work I will do documentation of how to integrate your code.
from vue3-table-lite.
Perhaps it can help. I have this message
<script lang="ts">
import { reactive } from 'vue';
import VueTableLite from 'vue3-table-lite';
Could not find a declaration file for module 'vue3-table-lite'. '/Users/mehdiambari/Desktop/Projets/NNP2/node_modules/vue3-table-lite/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/vue3-table-lite` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue3-table-lite';`Vetur(7016)
from vue3-table-lite.
Perhaps it can help. I have this message
<script lang="ts"> import { reactive } from 'vue'; import VueTableLite from 'vue3-table-lite';
Could not find a declaration file for module 'vue3-table-lite'. '/Users/mehdiambari/Desktop/Projets/NNP2/node_modules/vue3-table-lite/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/vue3-table-lite` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue3-table-lite';`Vetur(7016)
Did you add 「shims-vue.d.ts」to your 「src」folder?
├── dist
│ ├── ...
├── LICENSE
├── package.json
├── README.md
├── src
│ ├── App.vue
│ ├── main.ts
│ └── shims-vue.d.ts
└── tsconfig.json
If not, maybe you can try to create shims-vue.d.ts file and contents will be like
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
from vue3-table-lite.
I create a example by TypeScript.
Example.vue
<template>
<table-lite
:has-checkbox="true"
:is-loading="table.isLoading"
:is-re-search="table.isReSearch"
:columns="table.columns"
:rows="table.rows"
:total="table.totalRecordCount"
:sortable="table.sortable"
:messages="table.messages"
@do-search="doSearch"
@is-finished="tableLoadingFinish"
@return-checked-rows="updateCheckedRows"
></table-lite>
</template>
<script lang="ts">
import { defineComponent, reactive } from "vue";
import TableLite from "./components/TableLite.vue";
// create fake data1
const sampleData1 = (offst: number, limit: number): Array<rowData> => {
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;
};
// create fake data2
const sampleData2 = (offst: number, limit: number): Array<rowData> => {
let data = [];
for (let i = limit; i > offst; i--) {
data.push({
id: i,
name: "TEST" + i,
email: "test" + i + "@example.com",
});
}
return data;
};
// Define row data interface
interface rowData {
id: number;
name: string;
email: string;
}
export default defineComponent({
name: "App",
components: { TableLite },
setup() {
// Init Your table settings
const table = reactive({
isLoading: false,
isReSearch: false,
columns: [
{
label: "ID",
field: "id",
width: "3%",
sortable: true,
isKey: true,
},
{
label: "Name",
field: "name",
width: "10%",
sortable: true,
display: function (row: rowData) {
return (
'<a href="#" data-id="' +
row.id +
'" class="is-rows-el name-btn">' +
row.name +
"</a>"
);
},
},
{
label: "Email",
field: "email",
width: "15%",
sortable: true,
},
{
label: "",
field: "quick",
width: "10%",
display: function (row: rowData) {
return (
'<button type="button" data-id="' +
row.id +
'" class="is-rows-el quick-btn">Button</button>'
);
},
},
],
rows: [] as Array<rowData>,
totalRecordCount: 0,
sortable: {
order: "id",
sort: "asc",
},
messages: {
pagingInfo: "Showing {0}-{1} of {2}",
pageSizeChangeLabel: "Row count:",
gotoPageLabel: "Go to page:",
noDataAvailable: "No data",
},
});
/**
* Table search event
*/
const doSearch = (offset: number, limit: number, order: string, sort: string) => {
table.isLoading = true;
setTimeout(() => {
table.isReSearch = offset == undefined ? true : false;
if (offset >= 10 || limit >= 20) {
limit = 20;
}
if (sort == "asc") {
table.rows = sampleData1(offset, limit);
} else {
table.rows = sampleData2(offset, limit);
}
table.totalRecordCount = 20;
table.sortable.order = order;
table.sortable.sort = sort;
}, 600);
};
/**
* Table search finished event
*/
const tableLoadingFinish = (elements: Array<HTMLElement>) => {
table.isLoading = false;
Array.prototype.forEach.call(elements, function (element: HTMLElement) {
if (element.classList.contains("name-btn")) {
element.addEventListener("click", function () {
console.log(this.dataset.id + " name-btn click!!");
});
}
if (element.classList.contains("quick-btn")) {
element.addEventListener("click", function () {
console.log(this.dataset.id + " quick-btn click!!");
});
}
});
};
/**
* Row checked event
*/
const updateCheckedRows = (rowsKey: number) => {
console.log(rowsKey);
};
doSearch(0, 10, 'id', 'asc');
return {
table,
doSearch,
tableLoadingFinish,
updateCheckedRows,
};
},
});
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
</style>
from vue3-table-lite.
Perhaps it can help. I have this message
<script lang="ts"> import { reactive } from 'vue'; import VueTableLite from 'vue3-table-lite';
Could not find a declaration file for module 'vue3-table-lite'. '/Users/mehdiambari/Desktop/Projets/NNP2/node_modules/vue3-table-lite/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/vue3-table-lite` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue3-table-lite';`Vetur(7016)
Did you add 「shims-vue.d.ts」to your 「src」folder?
├── dist │ ├── ... ├── LICENSE ├── package.json ├── README.md ├── src │ ├── App.vue │ ├── main.ts │ └── shims-vue.d.ts └── tsconfig.json
If not, maybe you can try to create shims-vue.d.ts file and contents will be like
declare module '*.vue' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component }
Yes I do
from vue3-table-lite.
Ok thank you really much. Almost done.
Everything is working except buttons that are not reacting. (No message in the console). 😔
from vue3-table-lite.
Ok thank you really much. Almost done. Everything is working except buttons that are not reacting. (No message in the console). 😔
I has a mistake on origin example. But already fixed on the example. fix 「row.user_id」 to 「row.id」 on 「display�」 method please.
display: function (row: rowData) {
return ('<button type="button" data-id="' + row.id + '" class="is-rows-el quick-btn">Button</button>');
},
from vue3-table-lite.
Thank you so much for your help
The issue was is-rows-el missing in class inside my code
from vue3-table-lite.
Related Issues (20)
- Clear checked items when changing pages.
- Is it possible to add apexchart sparkline to doSearch() function? HOT 10
- Could not find a way to change the route of the app using the buttons on table HOT 1
- Is there a way to filter Published and Not Published? HOT 5
- How to change the checkbox "All Check" button to Indeterminate Checkbox when not all is selected? HOT 6
- Getting Warning for WATCH_ARRAY from vue3 HOT 5
- Getting roll up error HOT 4
- get-now-page event: How to use it HOT 6
- Expanding rowClicked for columnClicked and cellClicked HOT 5
- [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
- [Vue warn]: Hydration node mismatch HOT 5
- Hero text is visible on the side nav HOT 4
- Page-size and page-options not working 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.