Serenity: Programmatically fire quicksearch

Created on 2 Jul 2017  路  3Comments  路  Source: serenity-is/Serenity

Dear all,

I want to programmatically fill the Quicksearach input field and then fire the search.

Filling the quicksearch input box is no Problem. The Problem Comes with firing the search itself.

I have the following code, in XYZgrid.ts, which successfully fills the field but is unable to trigger the search Event:

protected onClick(e: JQueryEventObject, row: number, cell: number): void {
            // let base grid handle clicks for its edit links 
            super.onClick(e, row, cell);

            // if base grid already handled, we shouldn"t handle it again 
            if (e.isDefaultPrevented()) {
                return;
            }

            // get reference to current item 
            var item = this.itemAt(row);


            // get reference to clicked element 
            var target = $(e.target);


            if (target.hasClass("Location-link")) {
                e.preventDefault();

                // *** Get clicked text ***
                var bla = target[0].innerText;

                var qs = $(".s-QuickSearchBar").find(".s-QuickSearchInput");

                qs.val(bla);
                qs.focus();
                qs.trigger(jQuery.Event('keypress', { keycode: 13 }));

            }
        }

The idea is to fill the quick search input field with the text of a klicked link within the grid (following Volkan's basic samples) and then fire a search on this value.

Actually, I try to emulate a keyboard entry on the field with pressing "Enter".

Edit: After some Research, it seems that entering key strokes into a Input text field programmatically is suppressed for security reasons.

Therefore how can I trigger the quicksearch programmatically?

Thanks for your help and

With Kind regards,

John

Most helpful comment

Change trigger in

qs.trigger(jQuery.Event('keyup', { keycode: 13 }));

All 3 comments

Change trigger in

qs.trigger(jQuery.Event('keyup', { keycode: 13 }));

Hi Estrusco,

wow - it works :-) Who would think that keyup works and keydown not.

Thank you very much and

with Kind regards,

John

but I want to press enter key on button.
https://github.com/jan-molak/serenity-js/issues/238
Please help me if you have any solution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stepankurdylo picture stepankurdylo  路  3Comments

GitHubOrim picture GitHubOrim  路  3Comments

gfo2007 picture gfo2007  路  3Comments

Amitloh picture Amitloh  路  3Comments

Estrusco picture Estrusco  路  3Comments