Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vue-playground
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Artur Carvalho
vue-playground
Commits
a281df11
Commit
a281df11
authored
2 years ago
by
Artur Carvalho
Browse files
Options
Downloads
Patches
Plain Diff
Make space toggle selected isValid cell
parent
8ca86b51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Add initial libraries
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+8
-0
8 additions, 0 deletions
README.md
src/components/AgCellRenderer.vue
+0
-2
0 additions, 2 deletions
src/components/AgCellRenderer.vue
src/components/AgTable.vue
+36
-5
36 additions, 5 deletions
src/components/AgTable.vue
with
44 additions
and
7 deletions
README.md
+
8
−
0
View file @
a281df11
...
...
@@ -72,3 +72,11 @@ npm run format
```
Linting rules: https://eslint.vuejs.org/rules
### Gitlab Pipelines
1.
types are being checked on build
1.
formatting checked with prettier
1.
linting checked with eslint
1.
unit tests checked with vitest
1.
e2e wip with playwright
This diff is collapsed.
Click to expand it.
src/components/AgCellRenderer.vue
+
0
−
2
View file @
a281df11
...
...
@@ -2,8 +2,6 @@
import
type
{
IHeaderParams
}
from
"
ag-grid-community
"
;
const
props
:
any
=
defineProps
<
{
params
:
any
;
value
?:
any
}
>
();
const
params
=
props
.
params
as
IHeaderParams
&
{
value
:
boolean
};
console
.
log
(
params
?.
value
);
const
hasValue
=
params
?.
value
!==
undefined
;
// const f = (evt: any) => console.log("focus");
...
...
This diff is collapsed.
Click to expand it.
src/components/AgTable.vue
+
36
−
5
View file @
a281df11
...
...
@@ -22,7 +22,7 @@ const rows = [
{
make
:
"
Porsche
"
,
model
:
"
Boxter BoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxterBoxter
"
,
"
Boxter BoxterBoxter
BoxterBoxterBoxterBoxterBoxter
BoxterBoxterBoxterBoxterBoxterBoxter
"
,
price
:
72000
,
isValid
:
false
,
},
...
...
@@ -52,8 +52,33 @@ const rowData: any = ref(rows);
// const cellWasClicked = (evt: any) => {
// console.log("xxx cell was clicked", evt.value);
// };
// Hacky way to toggle by using up/down arrow:
// - get focused cell
// - check if space was pressed
// - if so and if cell is isValid, toggle its value
let
focusedCell
:
any
=
null
;
const
cellFocused
=
(
evt
:
any
)
=>
{
console
.
log
(
"
xxx cell was focused
"
,
evt
);
focusedCell
=
evt
.
api
.
getFocusedCell
();
};
// todo: don't pass full object
const
toggleSelectedIsValid
=
(
evt
:
any
)
=>
{
const
row
=
evt
.
api
.
getDisplayedRowAtIndex
(
focusedCell
.
rowIndex
);
const
cellValue
=
evt
.
api
.
getValue
(
focusedCell
.
column
,
row
);
const
col
=
focusedCell
.
column
.
colId
;
const
rowIdx
=
row
.
rowIndex
;
if
(
col
===
"
isValid
"
)
{
row
.
setDataValue
(
col
,
!
cellValue
);
}
};
const
onCellKeyPress
=
(
evt
:
any
)
=>
{
if
(
evt
.
event
.
code
===
"
Space
"
)
{
toggleSelectedIsValid
(
evt
);
}
};
// should be ColDef[]
...
...
@@ -67,12 +92,18 @@ const columnDefs = ref([
// menuIcon: "fa-bars",
// },
},
{
field
:
"
model
"
},
{
field
:
"
model
"
,
// autoHeight with wrapText expand column. It loses virtualization for that column though
// autoHeight: true,
// wrapText: true,
},
{
field
:
"
price
"
,
filter
:
"
agNumberColumnFilter
"
},
{
field
:
"
isValid
"
,
headerName
:
"
custom is valid
"
,
cellRenderer
:
AgCellRenderer
,
// headerCheckboxSelection: true, // this is to select multiple rows, not mark the custom component
// checkboxSelection: true,
// showDisabledCheckboxes: true,
...
...
@@ -101,7 +132,6 @@ const onFilterChanged = (evt: any) => {
const
get
=
async
()
=>
{
console
.
log
(
"
xxx GET call
"
);
const
url
=
"
https://www.ag-grid.com/example-assets/row-data.json
"
;
const
response
=
await
fetch
(
url
);
let
remoteRowData
=
(
await
response
.
json
())
as
ICar
[];
...
...
@@ -140,8 +170,9 @@ const multiSortkey = "ctrl";
:onSortChanged=
"onSortChanged"
:onFilterChanged=
"onFilterChanged"
:onCellFocused=
"cellFocused"
:onCellKeyPress=
"onCellKeyPress"
class=
"ag-theme-alpine"
style=
"height:
7
0vh"
style=
"height:
12
0vh"
:columnDefs=
"columnDefs"
:rowData=
"rowData"
:defaultColDef=
"defaultColDef"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment