The title may be a little confusing, let's dive into details: I have a BLB inherited list model called Documents, and the child item model is a regular BusinessBase inherited model Document. Consider the following situation:
The Documents list has 3 items, two of which is currently opened for editing (utilizing BeginEdit() ), the other one is not opened.
Now I'm trying to remove the closed document by calling list.Remove(doc), but the document file is not deleted since the actual filesystem delete operation is done in Child_DeleteSelf() in the Document class which is not fired until list.Save() is called. However I cannot simply call list.Save() because this will save all the other currently editing documents which is not intended.
Probably I made some silly mistakes somewhere, or is there a better way to accomplish this?
So you want a different behavior than that of the standard lists - which is for the save to:
You can override the RemoveItem method of the list to call a command object to do the actual immediate delete and the leave the child_delete method empty to do nothing in the child object.
Really appreciated for the quick reply. I suppose you suggest doing this:
protected override void RemoveItem(int index)
var item = this[index];
this.DeletedList.Remove(item); // since the underlying file is deleted, it should not be undoable.
now whenever list.Remove(item) is called, the actual file delete is performed, eliminate the need to call list.Save(). But then the normal collection undo capability is lost. I don't like to alter the normal Remove(item) behavior, so I think for me, adding a separate Delete(item) function into the collection class is a more practical solution, like this:
public void Delete(item)
Is this an OK approach ?
The only difference in your code above is that you must call a specific method on the list for remove.
That doesn't stop anyone (potentially) using your code and call the regular Remove by using DataBinding or built-in Remove/Delete in a grid.
None of the solutions will support n-level undo functions in that a "deleted" item will be recovers . the file is already deleted.
Luckily no grid in my circumstances, will use the code from my previous reply.
Copyright (c) Marimer LLC