Skip to main content
Solved

Problem "refresh" (recalculating field) of grid

  • October 19, 2021
  • 5 replies
  • 984 views
  • Translate All

Hi, Good night.

 

I want to recalculate the field (% Above Winner) when a new row is inserted/updated/deleted. I did the method (and it works) but when i put this method in a event of the same grid i got an error/debuggin visual studio warning. But if i put the method in other field (other tab etc, no in the same grid) it works.

Can you helpme please? i paste some images to explain me better.

 

 

1.- this is the grid. I need to recalculate the column “%  AboveWinner “(for all rows) for Add,Update, Delete action.
2.- when i put the method “getAboveWinners” in the update field event of this grid i got an “error”
This is the error.
When i put the method in other button/tab etc (not in the same grid) it works!
    public void getAboveWinners()
{
int countLowestValue=0;
decimal? lowestValue=0;
//we get the lowest value;
foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
if(lowestValue==0)
{
lowestValue=soLine.TotalBid;
}
else if(lowestValue>=soLine.TotalBid)
{
lowestValue=soLine.TotalBid;
}
}

foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
decimal? resultado=((soLine.TotalBid/lowestValue)-1)*100;
soLine.PercentageAboveWinner=resultado;
viewCEEstimateBidWinner.Update(soLine);
}
}

 

Can you help me please, thanks!

Best answer by Naveen Boga

Hi @eddiedaco  Since the problem is related to refreshing the grid. You can add the below at last of your code and verify.

Graph.ViewName.View.RequestRefresh();

 

Hope this helps!!

View original

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • October 19, 2021

Hi @eddiedaco  Since the problem is related to refreshing the grid. You can add the below at last of your code and verify.

Graph.ViewName.View.RequestRefresh();

 

Hope this helps!!

Translate

  • Author
  • Varsity I
  • October 26, 2021

Hi @Naveen B  

Graph.ViewName.View.RequestRefresh(); “works” (visually) but when i save the information. Its saves the “old” information not the new.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20

Which means cache values are NOT persisting to Save the values in database.

Did you debug and check did cache holds the updated values?

Translate

Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2

@eddiedaco When putting the getAboveWinners method in the fieldUpdated event, make sure the other rows have status Updated, otherwise the cache will ignore them and will not be saved:

foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
decimal? resultado=((soLine.TotalBid/lowestValue)-1)*100;
soLine.PercentageAboveWinner=resultado;
viewCEEstimateBidWinner.Update(soLine);
if(this.viewCEEstimateBidWinner.Cache.GetStatus(soLine) != PXEntryStatus.Inserted)
this.viewCEEstimateBidWinner.Cache.SetStatus(soLine, PXEntryStatus.Updated);
}

 

Translate

  • Author
  • Varsity I
  • February 1, 2022

The problem was the “update” of yourview.Update. for every iteration the “.update” show error. The solution was change .update for yourview.Cache.SetValue<yourDAC.yourField>
                (soLine, yourvalue)

Translate