Skip to content

Commit

Permalink
Fixes #3
Browse files Browse the repository at this point in the history
Add ability to enable cell editing and add an example to documentation.
  • Loading branch information
rob-white committed Dec 22, 2018
1 parent d3210f4 commit 581ede3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,36 @@ function(e, args) {
### SlickGrid Options
> Each of the base SlickGrid Grid options are also available. *See the [SlickGrid Grid Options Wiki](https://github.com/mleibman/SlickGrid/wiki/Grid-Options) for defaults and descriptions.*
## Available Events
## Enable Editing
> You can enable editing of cells by enabling the SlickGrid edit options and setting editors on the columns you want. *See the [SlickGrid Examples](https://github.com/mleibman/SlickGrid/wiki/Examples) for examples & cell editor info.*
```html

<template>
<slim-grid :editable="true" :column-options="columnOptions"></slim-grid>
</template>

<script>
import { Editor } from 'slickgrid-es6';
import SlimGrid from 'vue-slimgrid';
export default {
components: { SlimGrid },
data: () => ({
columnOptions: {
// Add a text editor to all columns. If you want to write your own custom cell editor, see below:
// https://github.com/mleibman/SlickGrid/wiki/Writing-custom-cell-editors
'*': {
editor: Editor.Text
}
}
})
}
</script>
```

## Available Events
> All events you can listen for on the SlimGrid component use the kebab-case syntax:
```html
<template>
Expand Down
4 changes: 3 additions & 1 deletion examples/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<div id="app">
<slim-grid :data="data"
:height="500"
:editable="true"
:column-options="columnOptions"
:grouping="groupByDuration"
></slim-grid>
</div>
</template>

<script>
import { Data } from 'slickgrid-es6';
import { Data, Editors } from 'slickgrid-es6';
import SlimGrid from "../src/components/SlimGrid.vue";
export default {
Expand All @@ -31,6 +32,7 @@ export default {
},
columnOptions: {
percentComplete: {
editor: Editors.Text,
groupTotalsFormatter(totals, columnDef) {
let val = totals.avg && totals.avg[columnDef.field];
if (val != null) {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/js/default-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export default {
onBeforeCellEditorDestroy: {
on(e, args) {
this.$emit("before-cell-editor-destroy", e, args);
},
after(e, args) {
this.dataView.refresh();
}
},
onBeforeDestroy: {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export default {
}

return _.mapValues(defaults, (value, key) => {
return _.isFunction(value) && ["groupTotalsFormatter", "formatter", "hidden", "order"].indexOf(key) === -1 ? value(defaults) : value;
return _.isFunction(value) && ["groupTotalsFormatter", "formatter", "hidden", "order", "editor"].indexOf(key) === -1 ? value(defaults) : value;
});
},

Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
},
autoEdit: {
type: Boolean,
default: true
default: false
},
autoHeight: {
type: Boolean,
Expand Down

0 comments on commit 581ede3

Please sign in to comment.