Serenity

How to Add Link in Grid or Listing Page in Senerity

How to Add Link in Grid or Listing Page in Senerity

Add Link in Senerity

Can Create Edit Link to Open our record in Edit mode by using EditLink Attribute


public class UserColumns
{
    [EditLink, DisplayName("UserId"), AlignRight]
    public string UserID { get; set; }
}

Here
- We added a link on Id Column on Listing page to open our record in edit mode


Add Customer Link on Listing / Grid Page

(Say if we need a delete button with each record in listing)

export class UserGrid extends Serenity.EntityGrid<UserRow, any> {

    constructor(container: JQuery) {
        super(container);
    }

    protected getColumns() {
        var columns = super.getColumns();

        columns.unshift({
            field: 'Delete Row',
            name: '',
            format: ctx => '<a class="inline-action delete-row" title="delete">' +
                '<i class="fa fa-trash-o text-red"></i></a>',
            width: 24,
            minWidth: 24,
            maxWidth: 24
        });
       
        return columns;
    }

    protected onClick(e: JQueryEventObject, row: number, cell: number) {

        super.onClick(e, row, cell);

        if (e.isDefaultPrevented())
            return;

        var item = this.itemAt(row);
        var target = $(e.target);

        if (target.hasClass('inline-action')) {
            e.preventDefault();

            if (target.hasClass('delete-row')) {
                Q.confirm('Delete record?', () => {
                    BillOfMaterialService.Delete({
                        EntityId: item.Id,
                    }, response => {
                        this.refresh();
                    });
                });
            }
       
        }
    }
}

Here
- We inserted a new column for delete having bin icon, shifted to left of the row (as first column)








Related Post

About Us

Community of IT Professionals

A Complete IT knowledgebase for any kind of Software Language, Development, Programming, Coding, Designing, Networking, Hardware and Digital Marketing.

Instagram