cancel
Showing results for 
Search instead for 
Did you mean: 

Textfield Value State problem

onur_sara
Participant
0 Kudos

Hi All,

I am using TextFields as cells of Table . I am setting ValueState properties of Texfields with sap.ui.core.ValueState.Error as dynamically .


My problem is  If I resize the browser window , valuStates of Textfields are being None automatically .

If do you have any solution please let me know .

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Onur,

Did you use formatter to set the value state dynamic for text field? Then there should not be any problem, even if you resize the browser window.

Check this sample for testing: JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

onur_sara
Participant
0 Kudos

Hi Sai ,

I did not use formatter . Because I am calling a Rest Service on change event of Texfield . If Ajax call returns error then I am changing state of Textfield as Error .

saivellanki
Active Contributor
0 Kudos

Onur,


OK, how are you setting the value state of text field in onChange event? Can you share the code?

Here is a sample: JS Bin - Collaborative JavaScript Debugging that I have created, try to enter a value > 10 in Address column, you can see the text field state changed to "Error".


Regards,

Sai Vellanki.

onur_sara
Participant
0 Kudos

Sai,

Yes , I am setting it on Change event . Problem occurs , when I set visibleRowCountMode property of table as "Auto" . And I have to set this property as "Auto". I think there is a bug .  I just made some changes on your code , please review .

JS Bin - Collaborative JavaScript Debugging

Thanks .

saivellanki
Active Contributor
0 Kudos

Hi Onur,

I got your problem now. You are using "Auto" for visibleRowCountMode. In result, what happens in the background is when you re-size the browser window the table rows get adjusted with respect to screen height. Since, the property value is set to "Auto".


To overcome the above issue, what you can do is use addEventDelegate method of table. So, when you re-size or maximize the screen it will hit the onAfterRendering event. Also, if you want to store the value that you are providing in text field, use model concept there.


I edited the JSBin, check now: JS Bin - Collaborative JavaScript Debugging


Regards,

Sai Vellanki.

saivellanki
Active Contributor
0 Kudos

Onur,


Proper testing is not done in the jsbin provided in my last response. But, you got an idea where you can write the logic. Let me know if there is any specific logic needs to be added.


Regards,

Sai Vellanki.

onur_sara
Participant
0 Kudos

Hi Sai ,


Yeah I got the idea , your solution is working very well


I just added some flag columns in my model   for each Textfields which I need to set Valuestates .

After I have  set this flags value on change event for this TextFields.

Finally checked value of flags onAfterRendering function like below code .


oTable.addEventDelegate({

  onAfterRendering : function(){

  var oModel = this.getModel();

  var tabledata = oModel.getData();

  var oRows = this.getRows();

  for(var i=0 ; i< tabledata.length ; i++)

  {

   

     if(tabledata[i].errmatnr == "X")

  oRows[i].getCells()[2].setValueState("Error");

     if(tabledata[i].errnetwr == "X")

  oRows[i].getCells()[8].setValueState("Error");

     if(tabledata[i].errmeins == "X")

  oRows[i].getCells()[10].setValueState("Error");

     if(tabledata[i].errwaers == "X")

  oRows[i].getCells()[11].setValueState("Error");

    

  }

  }

  },oTable);

Thanks a lot for your interest 

Best regards .

Answers (0)