2016 Oct 25 8:00 AM - edited 2024 Feb 03 5:55 PM
Greetings,
I have a Matrix Validate After event which results in infinite loop sometimes. Sometimes it executes correctly some other times i loops until death. Any ideas why this happens and if there is something i am not currently handling?
I add dates on the top right matrix and columns on the bottom matrix should unlock and lock when i remove the date
private void Matrix0_ValidateAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
{
switch (pVal.Row)
{
case 1:
if( ((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
Matrix1.Columns.Item(3).Editable = true;
else
Matrix1.Columns.Item(3).Editable = false;
EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);
break;
case 2:
if (((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
Matrix1.Columns.Item(4).Editable = true;
else
Matrix1.Columns.Item(4).Editable = false;
EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);
break;
Hi Varnavas,
The Validate event is triggered every time a control is "about to sync data with the data source". Action like clicking on another control will trigger the validate event on the current control.
One way to stop this from happening is to temporarily disable all events during your handling of the validate event:
public void AfterValidateHandler(ItemEvent e)
{
var currentEventFilters = application.GetFilter();
application.SetFilter(null);
// do your actions here
application.SetFilter(currentEventFilters);
}
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Varnavas,
If it's looping you can (using the debugger) see exactly where it triggers the validate again. Note that click is just one type of action that triggers the validate, if you write to another cell, click a button, focus another control, etc... all these will trigger it as well.
Make sure that in your that in your Matrix0_ValidateAfter you are not performing any operation that will trigger another validate.
Pedro Magueija
Still it does not make sense. Here is what happens:
1) i enter a value in the cell i click tab and everything is fine.
this ←code executes:
if( ((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
Matrix1.Columns.Item(3).Editable = true; ←←←←←←←
else
Matrix1.Columns.Item(3).Editable = false;
2) i don't enter a value in the cell i click tab everything is fine
this ← code executes
if( ((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
Matrix1.Columns.Item(3).Editable = true;
else
Matrix1.Columns.Item(3).Editable = false; ←←←←←←←
3) i enter a value in the cell i click tab and up until here its ok. i go back to the cell, erase the data click tab and it loops infinitely on the ELSE statement why? since in scenario 2 it executes normally. disabling a column of another matrix triggers validation on a different matrix?
After having remote aid from Pedro Magueija we managed to solve this using filters. Just a side not, its not the first time Pedro does something like this. He's an SDK Dictionary. any page you flip you learn something 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After submitting my code through a ticket to SAP Development, they returned back saying that we discovered a bug in the current event (matrix validate after which has now been marked as "to be fixed with a patch". So currently work with what Pedro suggested until we hear something new.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Note to my above code, the part
EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);
I was removed since it was causing worse things. You can see the behavior here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
109 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.