Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

OI Edit Table delete key

In OI Edit Tables, when you hit the "delete" key it will delete a complete row out of the edit table. I was wondering if there was a setting, or a way to programatically disable this behavior with the "delete" key.

Any thoughts?

Comments

  • Dan,

    What behavior would you want it to do instead?
  • I would like it to just delete what is in that particular cell - similar to what happens in an Excel spreadsheet.
  • Dan,

    Of course, I assume this is what you want to happen when the SRP EditTable is in navigation mode. If the cell is in edit mode and the content is selected, then you get the behavior you want already.

    I can see the value of a property that defines what the delete button will do in these situations. But for now the best way to handle this is to trap the BeforeDeleteRecords event and then use the Cancel property to prevent the event from continuing (make sure you are qualifying the event as synchronous.) Within this event handler you can then delete the content of the current cell.

    Will that work for you?
  • Don,

    Yes, this gets me pointed in the right direction. I'll have to come take that second OI class from you sometime soon!

    Thanks!
  • Dan,

    I wanted to verify that this would work as I expected. It does. Here is the code I used: BeforeDeleteRecords.OLE_EDITTABLE: SelPos = Get_Property(CtrlEntId, 'OLE.SelPos') ColPos = SelPos<1> RowPos = SelPos<2> Set_Property(CtrlEntId, 'OLE.CellText[' : ColPos : ';' : RowPos : ']', '') Set_Property(CtrlEntId, 'OLE.Cancel', True$) return
  • Don,

    The directions you gave me look like they pertain to the SRP EditTable, but I am looking for help with the OpenInsight Edit Table. I thought you were suggesting to use the Windows Library to find the BeforeDeleteRecords event, but I think we might be talking about two different things here. Do you have any ideas on how to accomplish this behavior with the delete key in an OpenInsight Edit Table? Sorry if I'm not very clear in communicating this stuff....

    Thanks,
    Dan
  • Hi Dan,

    Oops! My apologies. I totally assumed this was an SRP EditTable question. I wondered why you had posted this in the OpenInsight forum rather than the SRP EditTable forum. Thus, I had moved the thread. I have now moved the thread back. :-D

    Now that I know what you are really trying to accomplish, I will resist the obvious temptation to plug the SRP EditTable and just try to help you with your OI edit table task. Yes, this can be done with the OI edit table. Also, the general concept is the same. You will need to intercept the delete row action and clear the cell. The difference will be in the approach.

    We actually did something similar with one of our products that has been around for so long that we still use OI edit tables. The hard part will be intercepting the delete row action. OI does provide a DELETEROW event for edit table controls. However, this event is fired after the row is visibly deleted. There is a technique that you can use to restore the line. Some OI developers, including SRP, consider this to be sub-par. In fact, one of the reasons we created the SRP EditTable was so we could create true preemptive events.

    Fortunately, with newer versions of OI you can work some magic to get the same results. This is not built into the product, so you will have to roll out your own solution. The necessary tools to do this are documented in Sprezzatura's Prevention Row Deletion blog article. If you continue to use the OI edit table, you may want to read their entire "EditTable CookBook" series. I think you will find them valuable.

    Once you have stoped the delete row action, you can then use the ACCESSDATA property to clear the current cell.
  • Thank you Don! The information given on the blog worked great.

    Thanks,
    Dan
Sign In or Register to comment.