cancel
Showing results for 
Search instead for 
Did you mean: 

table refresh does not work with Message Box

Former Member
0 Kudos

Hi All,

I have a ui5 application on HANA for updating values.

On clicking update button, the value is updated and the table model is loaded with data again through the xsjs file. And thus the table refreshes to show new value immediately.

This function was working fine. But on adding a message box with success icon on clicking update, the refresh feature stops working properly. It works 5 out of 10 times. Sometimes, 1st update shows no result, 2nd update shows the values which was updated in the 1st time and so forth.

Also, the application stops to show new changes. It is as if it gets corrupted. Removing the message box code also doesn't help. Only way is to either make a copy of the app without the message box code and activate or else UNDO the changes and revert till before the addition of message box code.

Any idea why this is happening?

Help appreciated.

Thanks in advance

Ritu J

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182862
Active Contributor
0 Kudos

Hi Ritu

It is hard to tell unless you share some code.

-D

Former Member
0 Kudos

Hi Dennis,

There are two options I tried:

1. inside a function after update which contains the refresh of table models:

function afterUpdate()

           {

               //var rModel = new sap.ui.model.json.JSONModel("rModel"); 

               rModel.loadData("services/details.xsjs?det=details&d1="+selectedval);

              

               //var rsModel = new sap.ui.model.json.JSONModel(); 

               rsModel.loadData("services/details.xsjs?det=status&s1="+selectedval);

            

              

          // copied from open ui5 example

          jQuery.sap.require("sap.ui.commons.MessageBox");

          
// open a fully configured message box
           sap
.ui.commons.MessageBox.show("Ruling the world is a time-consuming task. You will not           have a lot of spare time.\nStill convinced to do it?",
           sap
.ui.commons.MessageBox.Icon.WARNING,
          
"This could be dangerous",
          
[sap.ui.commons.MessageBox.Action.YES, sap.ui.commons.MessageBox.Action.NO],
           sap
.ui.commons.MessageBox.Action.YES);

     }


There is no change. The message box does not seem to work but update and refresh works fine.


2. Inside the controller, on clicking the update button


update : function(j) {

       //alert("Open  update! ");

       var oSHTable = sap.ui.getCore().byId(j);

       var i = oSHTable.getSelectedIndex();

      

       if(i == -1)

       {

            alert("Please select a row to update");

            return;

       } 

       else if(i>=0)

       {

             var selectedRow = oSHTable.getContextByIndex(i);

             var selectedval = selectedRow.getProperty('roundid');

             var selectedval2 = selectedRow.getProperty('seqid');

             var selectedval4 = selectedRow.getProperty('supcomments');

             var selectedval3 = selectedRow.getProperty('READUPD');

                

             if(selectedval3==null)

             {

                 alert("Please enter reading" );

                 return -1;

             }

             if(selectedval4==null){

                 alert("Please enter comments" );

                 return -1;

                

             }

             if(selectedval3=="")

             {

                 alert("Please enter reading" );

                 return -1;

             }

             if(selectedval4==""){

                 alert("Please enter comments" );

                 return -1;

                

             }

             else

             {

           

                 var aUrl = 'services/update.xsjs?cmd=multiply'+'&d1='+ selectedval+'&d2='+selectedval2+'&d3='+selectedval3+'&d4='+selectedval4;

              

           

                 jQuery.ajax({ 

                           url: aUrl, 

                           method: 'GET', 

                           dataType: 'json', 

                           success: this.onCompleteMultiply2, 

                           error: this.onErrorCall2 });

                

                 alert("Updated!!!");

// copied from open ui5 example

          jQuery.sap.require("sap.ui.commons.MessageBox");

          
// open a fully configured message box
           sap
.ui.commons.MessageBox.show("Ruling the world is a time-consuming task. You will not           have a lot of spare time.\nStill convinced to do it?",
           sap
.ui.commons.MessageBox.Icon.WARNING,
          
"This could be dangerous",
          
[sap.ui.commons.MessageBox.Action.YES, sap.ui.commons.MessageBox.Action.NO],
           sap
.ui.commons.MessageBox.Action.YES);

                 return 0;

            

                 }

             }

       }

When the alert 'Updated!!!' is present, the code works fine as expected and refreshes correctly. Once I remove the alert, it shows all the problems.

May be the alert is buying some time to make the refresh work correctly. I cannot understand.

Thanks!

former_member182862
Active Contributor
0 Kudos

sorry Ritu for responding later

can you try to move

jQuery.sap.require("sap.ui.commons.MessageBox");


to the top of your javascript file. I hope to load the messagebox code earlier


Thanks

-D