Skip to content

Commit 546b727

Browse files
committed
clean up files
1 parent 4e87af9 commit 546b727

8 files changed

+76
-115
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@ag-grid-community/core": "^29.3.5",
13+
"@vueuse/core": "^10.1.2",
1314
"ag-grid-autocomplete-editor": "^3.0.1",
1415
"vue": "3.3.4"
1516
},

pnpm-lock.yaml

+55-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
import HelloWorld from './components/HelloWorld.vue';
32
import Grid from './components/Grid.vue';
43
</script>
54

@@ -11,8 +10,11 @@ import Grid from './components/Grid.vue';
1110
<a href="https://vuejs.org/" target="_blank">
1211
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
1312
</a>
13+
<br />
14+
<a href="https://ag-grid.com/" target="_blank">
15+
<img src="https://blog.ag-grid.com/content/images/2021/02/logo-white.svg" class="logo ag-grid" alt="Vue logo" />
16+
</a>
1417
</div>
15-
<HelloWorld msg="Vite + Vue" />
1618
<Grid />
1719
</template>
1820

@@ -29,4 +31,7 @@ import Grid from './components/Grid.vue';
2931
.logo.vue:hover {
3032
filter: drop-shadow(0 0 2em #42b883aa);
3133
}
34+
.logo.ag-grid:hover {
35+
filter: drop-shadow(0 0 2em #007bff);
36+
}
3237
</style>

src/components/Grid.vue

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,38 @@ export default {
55
AgGridVue,
66
GridCell,
77
GridCellEditor,
8-
GridCellEditorClassic,
9-
GridCellEditorWrapper,
108
},
119
};
1210
</script>
1311

1412
<script setup lang="ts">
13+
import { usePreferredDark } from "@vueuse/core";
1514
import "ag-grid-community/styles/ag-grid.css";
1615
import "ag-grid-community/styles/ag-theme-alpine.css";
1716
import { AgGridVue } from "ag-grid-vue3";
1817
import GridCell from "./GridCell.vue";
1918
import GridCellEditor from "./GridCellEditor.vue";
20-
import GridCellEditorClassic from "./GridCellEditorClassic.vue";
21-
import GridCellEditorWrapper from "./GridCellEditorWrapper.vue";
22-
import { ColDef } from "ag-grid-community";
19+
import { ColDef, GridReadyEvent } from "ag-grid-community";
2320
2421
const columnDefs: ColDef[] = [
2522
{
2623
headerName: "Make",
2724
field: "make",
28-
editable: true,
2925
cellRenderer: "GridCell",
3026
cellRendererParams: { name: "custom" },
31-
cellEditor: "GridCellEditor",
3227
},
3328
{
3429
headerName: "Model",
3530
field: "model",
36-
editable: true,
37-
cellEditor: "GridCellEditorWrapper",
3831
},
3932
{
4033
headerName: "Price",
4134
field: "price",
42-
cellRenderer: "GridCellEditor",
4335
editable: true,
44-
cellEditor: "GridCellEditorClassic",
36+
cellEditor: "GridCellEditor",
4537
},
4638
];
39+
4740
const rowData = [
4841
{ make: "Toyota", model: "Celica", price: 35000 },
4942
{
@@ -57,11 +50,18 @@ const rowData = [
5750

5851
<template>
5952
<div class="grid">
53+
<pre>{{ usePreferredDark() }}</pre>
6054
<AgGridVue
61-
style="height: 200px"
6255
class="ag-theme-alpine"
56+
:class="{ 'ag-theme-alpine-dark': usePreferredDark().value }"
6357
:columnDefs="columnDefs"
6458
:rowData="rowData"
59+
@grid-ready="
60+
($event: GridReadyEvent<typeof rowData>) => {
61+
$event.api.sizeColumnsToFit();
62+
}
63+
"
64+
dom-layout="autoHeight"
6565
>
6666
</AgGridVue>
6767
</div>

src/components/GridCellEditor.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const isCancelBeforeStart = () => {
3434
// If you return true, then the result of the edit will be ignored.
3535
const isCancelAfterEnd = () => {
3636
// our editor will reject any value greater than 1000
37-
return value.value > 1000;
37+
return value.value > 100000;
3838
};
3939
4040
onMounted(() => {
@@ -43,7 +43,6 @@ onMounted(() => {
4343
input.value?.focus();
4444
});
4545
46-
// console.log(this);
4746
});
4847
4948
defineExpose({

src/components/GridCellEditorClassic.vue

-45
This file was deleted.

src/components/GridCellEditorWrapper.vue

-45
This file was deleted.

src/components/HelloWorld.vue

-7
This file was deleted.

0 commit comments

Comments
 (0)