Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a filter to a page in serenity?

Tags:

c#

typescript

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 ($(e.target).hasClass('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 ?

Thanks!!

like image 275
Pedro Franco Avatar asked Aug 22 '17 20:08

Pedro Franco


1 Answers

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;
    }
like image 106
Pedro Franco Avatar answered Sep 25 '22 19:09

Pedro Franco