cancel
Showing results for 
Search instead for 
Did you mean: 

Alerting/halting user of error in table

Former Member
0 Kudos

I have validation function that I have for when a user inputs a string into an int only table, in my validation function i have a separate model that has a true or false flag, sets the error flag to true if the user inputted a string or something

validateNumber: function(oEvent){ 
       var oInput = oEvent.getSource();
       var oID = oInput.getValue( );
       if(isNaN(oID)){

         oInput.setValueState(sap.ui.core.ValueState.Error);

var oModel2 = new myJSONModel;

            oModel2 = sap.ui.getCore().getModel('errorModel');

            var oData2 = oModel2.getData();

            alert(oData2.error);

            oData2 = {error:true};

            alert(oData2.error);

            oModel2.setData(oData2)

and sets it to false if the valuestate is success, but I just realised that if one cell has a string in it and then they type an int into another the flag will be set to true even though it should still be false.

This flag stops a user from saving their new entries on the table if the error flag is true

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

HI Stam

Here is an example

Enter a non number to the cell like 'abc' will have the button disabled.

Example

-D

Answers (2)

Answers (2)

Former Member
0 Kudos

Is there a way to loop through the table to detect the red cells (errorstate cells)?

Qualiture
Active Contributor
0 Kudos

I would just set the valuestate upon each entered value in your table (so you would get a mix of 'white' and 'red' input fields in your table), and only upon submitting your data do the final check for any erroneous fields

Former Member
0 Kudos

That's true which it does sets the valuestates on the table, but I couldn't see anything in the api about checking the table for error valuestates, so thats why I was trying to set a flag. How could you search the table for the cells with the red error states? I can see them but I can't figure out how to loop through the table for the error cellls

Message was edited by: Stam anatic