cancel
Showing results for 
Search instead for 
Did you mean: 

Make input field editable on click of button

justin_kemp
Participant
0 Kudos

Hello Experts

I followed example SAPUI5 Explored and am trying to make an input field editable on click of a button. In the declaration I have marked it as editable=false which works perfectly fine.

I am using below code to make it editable.

In xml

<Input id = "i4" value="{pid}" width="200px" editable="false"/>

  <Input id = "i2" value="{pname}" width="200px" editable="false"/>

On click of button:

self.getView().byId("i4").seteditable(true);

  self.getView().byId("i2").setEditable(true);

both commands does not seem to work. what is wrong above?

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

debug to check if you are able to get the button self.getView().byId("i4")

justin_kemp
Participant
0 Kudos

Yes I am able to reach it.

The error is

Uncaught TypeError: self.getView(...).byId(...).seteditable is not a function

junwu
Active Contributor
0 Kudos

better to show full code........

you put those input in table?

if it is the case.

bind them to model, and manipulate the model

now you are manipulate the template, not the real ui control, if i am not wrong. that's why it is not working.

justin_kemp
Participant
0 Kudos

I tried bothways, inside and outside table. Check this:

JS Bin - Collaborative JavaScript Debugging

former_member182862
Active Contributor
0 Kudos

hi Justin

you are very close.

seteditable should be setEditable

thanks

-D

junwu
Active Contributor
0 Kudos

I change to this.getView().byId("i9").setEditable(true);

it is working for me.

justin_kemp
Participant
0 Kudos

This works now outside table. If it is inside table how to handle it.

Because as in my initial post I used


self.getView().byId("i2").setEditable(true);  which does not work. Here i2 is inside table.

junwu
Active Contributor
0 Kudos

i already told u

former_member182862
Active Contributor
0 Kudos

I would recommend that model way.

but an alternative

JS Bin - Collaborative JavaScript Debugging

Answers (0)