Pedro Franco Pedro Franco - 1 month ago 21
TypeScript Question

How to add a filter to a page in serenity?

I'm trying to make a filter for a page in serenity.

I have a page called Companies, and one button to open another page, CompanyUsers, users from this company.

enter image description here

It's already opening the new page, but it's giving me all the users, I want to filter by the row I have clicked.

I have tried changing the Controller of CompanyUsers adding a parameter, but after this I don't know how to set the filter in CompanyUsers.

My Onclick in CompaniesGrid.ts

protected onClick(e: JQueryEventObject, row: number, cell: number): void {
super.onClick(e, row, cell);

let item = this.itemAt(row);

if ($('usuario-row')) {
window.location.href = '/Cadastros/EmpresasUsuarios?empresaId=' + item.EmpresaId;

How can I do that with serenity ?
Is there an easy way to do that ?


Answer Source

I have found how to do that......

WIth QuickFilter on column and getQuickFilters on Grid.ts

protected getQuickFilters() {
        var flt = super.getQuickFilters();

        var q = Q.parseQueryString();

        if (q["jEmpresa"]) {
            var empresa = Q.tryFirst(flt, x => x.field == "EmpresaId");
            empresa.init = e => {
                e.element.getWidget(Serenity.LookupEditor).value = q["jEmpresa"];

        return flt;