When the editor opens, select another cell

Tags: #<Tag:0x00007f0b02823f70>

hello

I need to open A1 when the mouse clicks on other cells, such as C1. At this time, my A1 cell should remain open and refer C1 to my A1. Similar to the formula calculation in Excel.

  1. Double-click to open the A1 cell for editing.

  2. Click C1 cell,

3.A1 remains open, and the content should be C1.

Please help me, thank you.

Hello @MaLaTang

Currently there is no way to keep editor opened while clicking on another cell.

@aleksandra_budnik
hot.addHook(“afterBeginEditing”, function(row, col, event) {

});
How do I make editor changes here?

SetValue;

GetValue.

Just like

Handsontable. Editors. TextEditor. Prototype. The extend ();

But I don’t want to rewrite the editor,

I want to use hook events to implement values that appear when the editor is opened, values that appear when it is closed, and a separate renderer of the cell.

I made some custom changes in the editor, setValue,getValue,

However, when I modify the cell through hot.setdataatcell (), it does not trigger my custom setValue,getValue above;

If I double-click on the open cell to modify it, setValue and getValue will be triggered normally.

thank you.

is used to do something in the background but any UI changes (selection, styling, data changes) won’t appear as you need to rerender the table and rendering closes the editor.

@aleksandra_budnik
After I changed setCellMeta,

How do I rerender the report in javaScript?

And trigger the editor event I defined?

After I changed setCellMeta,

How do I rerender the report in javaScript?

the render() method applies your changes and repaints the table

@aleksandra_budnik
Trouble you again

hot.addHook("afterRenderer", function(TD, row, col, prop, value, cellProperties) {
   HE.cellCal(TD, row, col, prop, value, cellProperties);

})

cellCal : function(TD, row, col, prop, value, cellMeta) {
     do.......
 _this.hot.setDataAtCell(row,col,newVal);

}

I implemented something in it,
But after setDataAtCell() is called, afterRenderer is triggered again,
This is an infinite loop??

This is an infinite loop??

Yes, the renderer is called after the setDataAtCell method is called. You can add a condition to the renderer to use the setDataAtCell if the value differs from the setDataAtCell value. This will stop the infinite loop.

@aleksandra_budnik
Yes, now I’ve overridden the renderer, but how do I set the value of the current cell in the renderer?

I can’t use setDataAtCell because it will repeatedly call the renderer.

If I return TD directly; .

When I use getDataAtCell() elsewhere, I won’t be able to get the value.

I think there should be a way to implement setDataAtCell() in a custom renderer.

TD.innerHTML sets a value, you can also use it to wrap or transform the value, For example

TD.innerHTML = '<b>' + value + '</b>' bolds the value

@aleksandra_budnik
Thanks,
1.but getDataAtCell() when I need it; To return null, I need this value。
2.When I use a custom renderer, it actually renders the number of cells X2. Why is that?
minRows : 20, minCols : 20, hot.updateSettings({ renderer : cellRenderer }); function cellRenderer(hotInstance, td, row, col, prop, value, cellProperties) { debug("test"); if (typeof cellProperties.fm != "undefined") { } }

20 rows, 20 columns, 400 cells, 400 renderings.

@aleksandra_budnik

And, when I use td.innerhtml,

I’m going to double click on the cell, and it’s empty, and I guess that’s because I didn’t use setDataAtCell(),

If so, could you please ask the developer to help to understand? If possible, our team will purchase this product.

Thank you again.

Can you send a demo with your recent progress and expected output? I git a little bit lost about your recent version of the snippet

@aleksandra_budnik
Sorry, let me describe it again.

  1. I need to do some calculations when rendering.

  2. I need to be in the rendering process, please note that it is in the rendering process, not after the rendering. Look for anything in getCellMeta() that needs to be computed.

  3. I need to assign the result to the cell after calculation, using setDataAtCell();

  4. However, with setDataAtCell(), the render event is triggered, which is an infinite loop.

  5. If I use td.innerhtml =newValue, this works and doesn’t trigger a render event, but I can’t get the value from getDataAtCell() where I need it.

Thanks again.

I need to be in the rendering process, please note that it is in the rendering process, not after the rendering. Look for anything in getCellMeta() that needs to be computed.

currently can you only process the actions in the afterRender mode. But, maybe there are other hooks that can help, as the rendering is the last step when you make changes.

However, with setDataAtCell(), the render event is triggered, which is an infinite loop.
here https://jsfiddle.net/3h8s1x4q/ is an example on how to prevent the loop. Let me know if it works for you.

@aleksandra_budnik
Yes, I’ve now fixed this with afterRender, but it’s not perfect. Hope to be able to optimize somewhat in this respect later.

Thank you again. I wish you a happy New Year.

what else is missing in this process, @MaLaTang to meet your requirements?

Thank you. Happy New Year.

@aleksandra_budnik
For now, I’m getting what I need.
Then, why do multiple selected cells appear when typing Chinese? Look at the picture below。
This is perfectly normal for reentering characters or Numbers.

It looks like an issue with IME. When does it happen? I typed in my last demo https://jsfiddle.net/3h8s1x4q/ but did not get the issue (tested on Chrome 71/ Windows 10)