Skip to Content
0

Grid delete row submenu

Dec 15, 2016 at 10:37 AM

217

avatar image

I have a Grid on a custom form, where the user should add and delete rows before processing the results (I used a DataTable for datasource). I could create the row adding functionality, but the delete action won't persists to the DataTable.

I enabled the right click 'delete row' menu (id: 1293), and If the user press it, it deletes the row visually, but the row won't get deleted from the DataTable.

I tried to handle the event, when the delete row is pressed, after the press, I could delete the row from the datatable manually, but If I catch a MenuEvent (Menu Click, MenuID check), I won't have a "row" parameter, so I don't know which row to delete. The grid is also missing such an event (OnRowDelete or similar).

How can I persists the delete action to the Grid?

(I am using SAP 9.2 with UI and DI API C#)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

DIEGO LOTHER Dec 15, 2016 at 11:02 AM
1

Hi Szabolcs,

In this case you need to combine the RightClickEvent. When the user execute a right click action you receive this event with a parameter of the type ContextMenuInfo in this parameter you can see the ItemUID and colUID, so, keep the values in a global variable and then use this values on your menu event.

The flow is the following:

  1. RightClickEvent before action
  2. MenuEvent
  3. RightClickEvent after action

Hope it helps.

Kind Regards,

Diego Lother

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I check it with Event Logger and it seems like the flow is:

  1. Right Click Before = true
  2. MenuEvents
  3. Right Click Before = false

I will try it, but I need to be careful not to mess with other forms that are open (same Form Type).

0

Hi Szabolcs,

Yeap, you are correct. I wrote wrong the flow. Sorry for the mistake.

P.S: I corrected my mistake.

Kind Regards,

Diego Lother

0
Pedro Magueija Dec 15, 2016 at 12:35 PM
0

Hi Szabolcs,

There are two other alternatives.

1. Force the user to select a line before allowing the menu action to be handled (you can check during the menu event if lines are selected)

2. Check if a cell has focus using the CommonSettings and use it's row index (does not work for completely disabled grids).

The third option is what Diego suggested with globals.

Pedro Magueija

LinkedIn | Twitter | Blog

Show 2 Share
10 |10000 characters needed characters left characters exceeded

The MenuEvent object (that is passed as pVal on MenuEvents) does not have a FormUID, so I don't know which Form to get from SBO Application.

Also, the Grid's CommonSettings member only allows to color/format the cells.

0

Hi Szabolcs,

You're right, it's not in the CommonSettings. It's in the Grid itself.

grid.GetCellFocus();

It returns a CellPosition object.

Pedro Magueija

LinkedIn | Twitter | Blog

0