Update cell value

Hello again, I need some help.

First of all I have a hottable bind by settings:

  <hot-table [settings]="settings" hotId="planInstance"></hot-table>

On this I have a beforeChange event where I check the content users typed in into a cell and validate it, in some cases I need to change that cell value . (Eg: User type in cell : “xou” and I want to delete “o” and let in cell only “xu” )

Is there any way to achieve this? To modify that cell value?

Have you tried onBeforeChange instead of beforeChange?

onBeforeChange doesn’t even trigger on my side

The problem is that this part :
constructor(private hotRegisterer: HotRegisterer) { }
is undefined … when I try to acces this.hotRegisterer it is undefined

  const hot = this.hotRegisterer.getInstance(this.instance);
  hot.setDataAtCell(0,4, "x");

this result into
Uncaught TypeError: Cannot read property ‘setDataAtCell’ of undefined

Try getting the instance by using the ID you gave to hot-table. This works for me:

<hot-table hot-id="tableId">

JS:

hotRegisterer.getInstance('tableId');

hotRegisterer is undefined for me… I solved this with beforeChange event, and modify 4rd argument

If I bind the table using settings , is there any way I can refresh settings value in order to Refresh all table settings

Are you using Angular?

In my app, using Angular 1 we’re instancing hotRegisterer in the controller, like so:

controller: function(
  hotRegisterer
) 

Hope it helps

Hi @badiu.alexandru.alin

Do you have any more questions? I’d be happy to assist you.

thank you for your help @thiagarajan

1 Like

I am using Angular 4

Yes @aleksandra_budnik, I would want to know how can I set some cells read-only and change that cell style. I could achive that using beforeRenderer event, but it calls every time I change something on table and my app is working very hard … I need a fast solution

I could resolve some things using workarounds, but I really need to take hot-table instance, and I cannot catch it . I tried with HotRegisterer but when I call it I get undefined … How can I take hot instance reference

One workaround was to use use AfterRenderer event and save instance using cellProperties, but it load every time I change a cell in table and my page is working very hard… Is there any event loading only once from where I can take hot instance?

Hi @badiu.alexandru.alin

are you using the Angular wrapper or Vanilla?

Basically if you want to change a value in the editor you need to write a custom editor. If you want to change[quote=“badiu.alexandru.alin, post:1, topic:1593”]
(Eg: User type in cell : “xou” and I want to delete “o” and let in cell only “xu” )
[/quote]

then you can do it via afterChange hook.
Here http://jsfiddle.net/handsoncode/1ffp5kan/ is a similar example where I change the first letter of a value to Y if the value hasn’t got it as a first letter. To check it just type anything in the D column.

Hi @aleksandra_budnik I could edit cell value… I am using Angular wrapper … My problem now is that I cannot take hot table instance… i get undefined anytime I try to take hot instance

I could resolve some things using workarounds, but I really need to take hot-table instance, and I cannot catch it . I tried with HotRegisterer but when I call it I get undefined … How can I take hot instance reference

One workaround was to use use AfterRenderer event and save instance using cellProperties, but it load every time I change a cell in table and my page is working very hard… Is there any event loading only once from where I can take hot instance?

I get undefined when I try this … hotRegisterer is undefined on my project

Hi @badiu.alexandru.alin

after updating to a newer version of angular-cli we are no longer to use Handsontable PRO inside the Angular wrapper.
Are you using the older version of angular-cli or did not use it at all?

I use angular/cli - 1.4.4

@aleksandra_budnik should I downgrade my angular-cli? or what? I really need to catch hot instance

I will ask our Angular developer for some feedback and be back to you later today.

@aleksandra_budnik ok , thank you,I will be waiting for your feedback because I really need to catch that instance for future development on my app

Hi @badiu.alexandru.alin

Our developer is currently working on making ZoneJS compatible with Angular wrapper (without workarounds). Have I already send you a sample app that uses Handsontable PRO inside the wrapper (before the Angular-cli update)?