Prevent [DEL] keyboard key from deleting ultragrid row?

Is there any way to intercept the physical Delete]keyboard key before it deletes a ultragrid row?

Why: I have a form customization with a UD table ultragrid, basically a change order type grid. I need to prevent deletion of a grid row if the row’s Checkbox01 is set true. These rows have been approved by the customer and need to remain for reporting. I have setup a button to delete selected “unapproved” rows, but we’ve found that if a user clicks the keyboard Delete key it still deletes the row.

I’ve tried Data and Method BPMs on the UD tables record, but neither seems to stop the Delete key.

Going to try this I found on Infragistics keyboard handling
Keyboard Handling - Infragistics Windows Forms™ Help

1 Like

You should be able to throw an event handler on KeyPress on the grid in question. Perform some logic and then call args.Handled = true as needed to ignore

FWIW - This is a problem in the BAQ Designer too. If you go to change the Label of a field in the fields Display Fields- > Column Select, highlight part of it and hit the delete key, you can lose the row. No big deal if it was from a DB table. But if it was a Claculated field … buh-bye…

You might get lucky and have the delete confirmation window pop up. But if the very next key you press is the space bar, it will most likely activate the “Yes” button on that delete warning. :frowning:

1 Like

I’ve been a victim of that myself. :wink:

¯_(ツ)_/¯ The link I found seems to agree, but hasn’t worked for me yet. Probably something I’m missing though as I’m not as comfortable with form code.

Is it as simple as assigning the DEL key to another function in the hot key settings?

Set it to the function “Navigator” I’ve never been able to figure out what that was.

I need to stop any user who opens the form from deleting “approved” rows. It’s the Sales Order form too, so I only want it to affect when they’re on the tab with the UD grid. :frowning: I was hoping just send DEL key to the Delete button function I have setup or to ignore the keypress at all.

But so far it’s doing standard delete.

FWIW - It looks like it was fixed in 10.2.300. and by “it” I mean deleting a row with the DEL key.

EDIT

It looks like you have to have selected the whole row for the delete key to “delete record”

Here I set the cursor to the middle of the RM Name field and hit DEL acouple of times. it deletes the chars. After selecting the row and hitting DEL, I get the warning.

del%20key

1 Like

There is a BeforeRowDelete event where you can cancel the event.
It’s built right on the grid
Just go to events
Select your grid
Select DataEntryGrid
Pick a random GetNew
Then epicor will create 4 events you can delete the rest but the delete event you can use to either cancel the delete or invoke one of your functions

2 Likes

Nice to know.
Often these little “features” in E10 are what get me…

Thanks again Jose, that worked perfect!

I am public cloud (not yet live, so in our test environment), so we are on 10.2.600.4. In the Form Event Wizard, I do not see the BeforeRowDelete event. @josecgomez has this changed?
FormEventWizard
With a test account (that has no ability to change any column in the child table), I was able to delete the row without the “Delete Confirmation” popup. @ckrusen did something change on this too?

That is still there you need to select Data Entry Checkbox on the Events Tab (not the Form Event Wizard)

Did you check your options settings for that form?

image

@josecgomez thank you for clarifying. I found it here:
EventWizardBeforeRowDelete

Now it looks like I will need to write some code (my weakness).
I think I would need to verify the user group and if the user is not a member of a particular group, disallow and display a popup that states, you are not authorized to delete this information. How would that code look?
Also, the buttons “Update All Event Code” or “Update Selected Event Code”; are they referring to “all” as the three custom codes and “Selected” as only the blue highlighted custom control (in my picture epiUltraGirceC1_BeforeRowsDeleted)?

This code will check if the current user belongs to the specified security group

private bool Security(string groupID)
    {
        // Wizard Generated Search Method
        // This search method will be called from another method in custom code
        // For example, [Form]_Load
 
        bool recSelected;
        Ice.Core.Session session = (Ice.Core.Session) oTrans.Session;
        bool belongs = false;
        string whereClause = "DcdUserID='"+session.UserID+"'";
        System.Data.DataSet dsUserFileAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "UserFileAdapter", out recSelected, false, whereClause);
        if (recSelected)
        {
            System.Data.DataRow adapterRow = dsUserFileAdapter.Tables[0].Rows[0];
 
            // Check to see if User belongs to BRANCH User Group
             
                if(adapterRow["GroupList"].ToString().ToUpper().Contains(groupID.ToUpper()))
                {
                    belongs = true;
                }           
        }
        return belongs;
    }
1 Like

Calvin,
Yes, confirm Delete is checked.
OptionsConfirmOnDelete

With the 2nd option (“Confirm Delete of newly added row”) unchecked. You will not get the dialog if it is a row that has been added, but not yet saved.

grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
3 Likes