-
Notifications
You must be signed in to change notification settings - Fork 804
Grid Adding Active Delete (Delete Undelete) to a Grid
Victor Tomaili edited this page May 3, 2021
·
1 revision
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'; }
//....
}
}
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions