Autofill - override

Tags: #<Tag:0x00007f8b19ec6ae8>

Can i override the AutoFill behaviour for the below scenario?

I need to appy a specific calculation before autofilling the value in destination cells.

See the attached screenshot. I want to drag the value in JUN column of first row to the columns JUL, AUG and SEP. So i will select JUN cell and drag it to the right to copy the value (40 in this case) to JUL, AUG and SEP columns.

Hoewver, if the column is AUG, i need to copy twice the value in JUN… In other words, it should copy 80 to AUG column and 40 each to JUL and SEP columns. How can i override the default Autofill behaviour?

I tried overriding in beforeAutoFill hook, but no luck. Could you please suggest a possible solution?

Hey @prasanth.sivakumar

you can try with the beforeAutofil hook. You can also try to check the beforeChange hook as it is also responsible for changing the value.

Aleksandra, i tried updating the value to 80 in beforeautoFill hook, however, an AutoFill event is triggered after that (as observed in afterchange) that overwite it back to 40.

onBeforeAutofill = (hotInstance, start, end, data ) => {

var pastePush= [];
var newVal = 80;

pastePush.push([myrow, hotInstance.colToProp(mycol), newVal])

hotInstance.setDataAtRowProp(pastePush, ‘customPaste’);

return true;

}

I’m thinking of overriding this in the afterChnage hook… if it is Autofill, will apply the required calculations there… Any other thoughts?

If there is an afterAutofill hook, that would solve my problem (like afterpaste hook) !!!

Hey @prasanth.sivakumar

there’s no afterAutofill hook. But as you wrote it should be done with the afterChange hook.

It works with afterChange… but considering adding an afterAutoFill hook as a new feature… the more hooks you have, the more flexibility developers will get… Thank you

agree in 100%. I’ve just added the request to our Github board https://github.com/handsontable/handsontable/issues/6135 and set a notification to update this forum topic once we get the new hook ready.

Hi @prasanth.sivakumar

I have good news! We’ve just released 8.0.0-beta2 that fixes the mentioned issue. We won’t be closing this ticket now. It will be closed after we release the final 8.0.0 version of Handsontable.

Here’s a full list of changes https://github.com/handsontable/handsontable/releases/tag/8.0.0-beta.2
NPM https://www.npmjs.com/package/handsontable/v/8.0.0-beta.2

All feedback’s appreciated. Thank you for your input.

To inform anyone interested in the afterAutofill hook. It has been added to beta2 and stable 8.0.0 version https://github.com/handsontable/handsontable/issues/6135