api.on()
Description
Allows attaching a handler to the inner eventsUsage
api.on(
event: string,
handler: function
): void;
Parameters
event
- (required) an event to be firedhandler
- (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>
import { Button } from "@wx/svelte-core";
import { Grid } from "@wx/svelte-grid";
import { data, columns } from "./common/data";
let api;
function doScroll(row, column) {
api.exec("scroll", { row, column });
}
$: if (api) {
api.on("scroll", () => {
console.log(`Scrolling detected`);
});
}
</script>
<Button type="primary" click={() => doScroll(data[0].id, columns[1].id)}>
Scroll to First Row / Column
</Button>
<Grid bind:api {data} {columns} />
Related articles: