You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to be able to extend or override the internal services of revogrid. It's currently possible to hook into the events and customise the grid for our needs, but for some changes it would be great to change the default behaviour.
For example:
Change the autofill behaviour to automatically increment the value instead of just copying the value.
Currently we can hook into the beforeautofill event and add some custom logic, but it's quite complex.
onBeforeAutoFill($event: Event) {
const detail: { colType: "rgCol", type: "rgRow", newData: { [key: number]: { [key: string]: unknown } }, oldRange: { x: number, y: number, x1: number, y1: number }, newRange: { x: number, y: number, x1: number, y1: number }, mapping: { [key: number]: { [key: string]: { colProp: string, rowIndex: number, colIndex: number } } } } = ($event as any).detail;
// only single column supported
if (detail.oldRange.x != detail.oldRange.x1 || detail.oldRange.y != detail.oldRange.y1 || detail.newRange.x != detail.newRange.x1) {
$event.preventDefault();
return;
}
let i = 0;
for (const idx in detail.mapping) {
const newData = detail.newData[idx];
const keys = Object.keys(newData);
if (keys.length != 1) {
$event.preventDefault();
return;
}
const key = keys[0];
const mapping = detail.mapping[idx];
const myMapping = mapping[key];
if (key == "number") {
const value = newData[key];
const newValue = value + index + 1
newData[key] = newValue
}
i++;
}
}
The text was updated successfully, but these errors were encountered:
ATM when I want to overwrite it I just make a plugin and drop original event replacing it with mine. So technically it's getting to be a small service of mine instead of the one from core
I want to understand which approach seems more favorable from your perspective and we can consider this in the future
Thanks for your reply! Yes, most cases will be covered by a plugin. But in my example above, the service already does a great job and only a small change would be required. My code in a plugin or outside will require a much more complex and larger solution.
It would be great to have a simple dependency injection system where I'm only able to override a small part.
It would be great to be able to extend or override the internal services of revogrid. It's currently possible to hook into the events and customise the grid for our needs, but for some changes it would be great to change the default behaviour.
For example:
Change the autofill behaviour to automatically increment the value instead of just copying the value.
Currently we can hook into the beforeautofill event and add some custom logic, but it's quite complex.
The text was updated successfully, but these errors were encountered: