Skip to content

Commit

Permalink
feat: add event dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf committed Jun 10, 2021
1 parent d7347fd commit e771733
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gridjs-svelte",
"version": "1.0.0",
"version": "1.1.0",
"description": "A Svelte wrapper component for Grid.js",
"svelte": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
10 changes: 9 additions & 1 deletion src/gridjs.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount } from "svelte";
import { onMount, createEventDispatcher } from "svelte";
import { Grid } from "gridjs";
import type { Language } from "gridjs/dist/src/i18n/language";
import type { ServerStorageOptions } from "gridjs/dist/src/storage/server";
Expand All @@ -15,6 +15,8 @@
let node: Element;
const dispatch = createEventDispatcher();
export let width: string = "100%";
export let height: string = "auto";
export let autoWidth: boolean = true;
Expand Down Expand Up @@ -74,6 +76,12 @@
className,
});
instance.on('cellClick', (...args) => dispatch('cellClick', {...args}))
instance.on('rowClick', (...args) => dispatch('rowClick', {...args}))
instance.on('beforeLoad', (...args) => dispatch('beforeLoad', {...args}))
instance.on('load', (...args) => dispatch('load', {...args}))
instance.on('ready', (...args) => dispatch('ready', {...args}))
onMount(() => {
if (node) {
instance.render(node);
Expand Down

0 comments on commit e771733

Please sign in to comment.