on 06-22-2016 11:38 PM
Hello everyone,
I am new in SAP Business One SDK and I am currently doing some tests with Matrix that I still cant get a solution, btw I am developing in VB.NET!
What I was trying to add or well activate is the Menu for a Matrix which I could enabled with this after the form I created is added to SAP collections
_oForm.EnableMenu("1292", True) 'AddRow Menu
_oForm.EnableMenu("1293", True) 'DeleteRow Menu
But when I click in deleterow it endeed deletes it but when I tried to add new row It does nothing, I am not sure why!!
So I would like some help with 2 things
1) How can I get the addrow to work?
2) How can I handle the event of both menus after action? Since Add new row, will just add the new row and i would have to set the number in the column, same goes to delete which just deletes it and I would have to reset all the matrix row number so they are all in order
Matrix is loaded with User Table info
Thanks
Appreaciate help
Hi Jean,
1) How can I get the addrow to work?
You have to add the row yourself. Unlike the delete which occurs automatically, you'll need to add the row to the matrix. There are several ways to do it. The recommended way would be to add a row to the datasource and load it from there. This will ensure the datasource is up-to-date with the matrix.
2) How can I handle the event of both menus after action? Since Add new row, will just add the new row and i would have to set the number in the column, same goes to delete which just deletes it and I would have to reset all the matrix row number so they are all in order
If you are handling both events, please note that you should prevent the auto delete that B1 executes. Otherwise the behavior will be strange. To do that capture the event mentioned by and make sure the BeforeAction is true (only for the delete menu). Then delete the row yourself and set the BubbleEvent to false (this prevents B1 from auto deleting the row).
Best regards,
Pedro Magueija
View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks it workds I could handle the menu event like Edi said with SAPbouiCOM.BoEventTypes.et_MENU_CLICK but now I am facing another problem.
How can I know what row was selected or where was it clicked?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a question I would love to hear the answer from other.
I have no idea, the event argument does not give you this information.
For me, If I had to get the line, I do a work around using a global variable.
Catch the event before item click, set the global variable.
On the Menu event, I read the global variable.
Very ugly solution.
But most of the time, I don't need the know which line gets deleted.
Just do a flush to datasource and load back the datasource, you will get your matrix and datasource sync'ed
Regards
Edy
Hi guys,
I can tell you what I do and maybe it works for you as well. There are two options:
1) Allow the grid to have selectable rows, then when the event occurs check which row is selected.
2) If your grid is not read-only (all columns disabled) you can use the current cell focus oGrid.GetCellFocus. This will give you the indexes of the focused cell.
Normally I use the an option that applies, which is always dependent on the situation.
Thanks for the input.
Both your workarounds are not safe.
for point 1, when the user right click on the data area instead of the row header, the row will not get selected.
for point 2, if the user right click on the row header, your active cell will be incorrect. Partial read-only grid will also pose this problem.
And the main problem is you don't know where your user will click,
Regards
Edy
for point 1, you're right but you can select it when the row header is left-clicked (I do this as well);
for point 2, you can also select an available cell (not read-only, that's why this approach is only for grids that do have available cells);
In any of these cases you can use them safely (I'm using them). It does require to code those cases.
Please note that using a global variable is also an alternative. Just that I'm biased to avoid global's whenever it's possible. (What happens when two forms (same type) are open? Now we must have a map of global's...).
Pedro Magueija
If this answer is helpful or correct, marking it as such is a form of saying thank you.
Absolutely agree with you. That would be the best solution.
Perhaps we can propose it in IDEA place. What do you think?
Cheers.
Pedro Magueija
If this answer is helpful or correct, marking it as such is a form of saying thank you.
Done. Created in
Regards
Edy
Up voted.
Pedro Magueija
If this answer is helpful or correct, marking it as such is a form of saying thank you.
Hi,
All menu events are handled in the BoEventTypes.et_MENU_CLICK event.
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.