I can’t do Onblur/Onvaluechanged

Asked

Viewed 40 times

-1

I’m using the DevExpress, when I do direct by HTML works, but with the dxi-item no, probably because I’m using onValueChanged incorrectly...

FORM 1

Component.html

<dxi-item
  dataField="cep"
  autocomplete="off"
  [colSpan]="2"
  [label]="{text: 'CEP'}"
  [editorOptions]="{onValueChanged: cepChanged}">
</dxi-item>

Component.

ConsultaCEP(cep) {
   console.log("Consultar CEP: " + cep);
}
cepChanged(e){
   this.ConsultaCEP(e.value);
}

Does not log in

Error

ERROR Typeerror: this.Consultacep is not a Function

FORM 2

Component.html

<dxi-item
  dataField="cep"
  autocomplete="off"
  [colSpan]="2"
  [label]="{text: 'CEP'}"
  [editorOptions]="{onValueChanged: ConsultaCEP}">
</dxi-item>

Component.

ConsultaCEP(e) {
   console.log("Consultar CEP: " + e.value);

   this.service.consultaCEP(e.value)
     ....
}

LOG RESULT

Consultation CEP: 0123456

Error

ERROR Typeerror: Cannot read Property 'consultaCEP' of Undefined

I repeat, in both ways, making HTML work.

It’s been two days since I texted their support and got no response...

  • pq your method starts with uppercase letter?

  • It wasn’t me who did it, I’m only responsible for maintenance and it’s really relevant? They are good practices, okay, but right...

1 answer

0

Using the FORMA 2 described above, I gave a bind and it worked:

construtor(private service: Service){
    this.ConsultaCEP = this.ConsultaCEP.bind(this);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.