Grid Adding Active Delete (Delete Undelete) to a Grid - serenity-is/Serenity GitHub Wiki
Splitted the cheat sheet of Wesley Huang into more specific parts for easier finding the topics.
Being able to add active delete/undelete is simple. Add an "IsActive" Int16 field to the table you wish to use active delete on and then do the following:
[ConnectionKey("Default"), TableName("[tbl].[xyz]"), DisplayName("Entries"), InstanceName("Entry"), TwoLevelCached]
[ReadPermission("Administration:General"), ModifyPermission("Administration:General")]
public sealed class xyzRow : Row, IIdRow, INameRow, IIsActiveRow, IIsActiveDeletedRow //<---
{
//...
[NotNull, Insertable(false), Updatable(true)]
public Int16? IsActive //<---
{
get { return Fields.IsActive[this]; }
set { Fields.IsActive[this] = value; }
}
Int16Field IIsActiveRow.IsActiveField //<---
{
get { return Fields.IsActive; }
}
//...
public class RowFields : RowFieldsBase
{
//...
public Int16Field IsActive; //<---
//...
}
}
public UndeleteResponse Undelete(IUnitOfWork uow, UndeleteRequest request)
{
return new MyUndeleteHandler().Process(uow, request);
}
private class MyUndeleteHandler : UndeleteRequestHandler<MyRow> { }
[HttpPost, AuthorizeDelete(typeof(MyRow))]
public UndeleteResponse Undelete(IUnitOfWork uow, UndeleteRequest request)
{
return new MyRepository().Undelete(uow, request);
}
namespace FMCorpIntranet.Default {
@Serenity.Decorators.registerClass()
export class EmployeesGrid extends Serenity.EntityGrid<EmployeesRow, any> {
protected getIsActiveProperty() { return EmployeesRow.isActiveProperty; } //<----
protected getColumnsKey() { return 'Default.Employees'; }
//....
}
}