Skip to main content

api.on()

Description​

Allows attaching a handler to the inner events

Usage​

api.on(
event: string,
handler: function
): void;

Parameters​

  • event - (required) an event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)
info

The full list of the Grid actions can be found here

Example​

In the example below we output to the console that the scroll action is detected.

<script setup>
import { Button } from "@svar-ui/vue-core";
import { Grid } from "@svar-ui/vue-grid";
import { data, columns } from "./common/data";

const api = ref(null);
function doScroll(row, column) {
api.value.exec("scroll", { row, column });
}

function init(api){
api.on("scroll", () => {
console.log(`Scrolling detected`);
});
}
</script>

<template>
<Button type="primary" :onclick="() => doScroll(data[0].id, columns[1].id)">
Scroll to First Row / Column
</Button>

<Grid ref="api" :init="init" :data="data" :columns="columns" />
</template>

Related articles:

Related sample: Events