toni_bezic
Rookie

Wrong results in search with enter button

Hi! I have a problem with search results. On smartform when I click Search button, I get ok results on first page and every other page. But, when I click Enter button, the first page results are random, than I go to the second page and there I have ok results, then I go back on first page of results and they are corrected and ok. How can I get ok results on first result page after clicking Enter, without this random bug page results?

Tags (2)
0 Kudos
5 Replies
Prineel
Scout

Re: Wrong results in search with enter button

Hi @toni.bezic,

What search controls are you using, is it possible for you to upload screen shots so we have a better idea of your scenario?

 

Kind Regards

Prineel

0 Kudos
toni_bezic
Rookie

Re: Wrong results in search with enter button

ca70005d-6e51-4993-bfa0-5840ee055aab.png
first page results
91798d63-3dff-4f6c-8d92-887c81509f01.png
second page results

then I go back to the first page and get this kind of results: 

6d294f33-66b8-411a-a399-1d02b492ecff.png
first page after klicking second page and going back

I search by clicking Enter button on my keyboard. When I search by clicking Pretraži (Search button) then I get first page with elektro results.

On my SmartForm I use script for searching every parameter defined in expression:

 <script> $('[name="Subject Title Text Box"]').keypress(function(event) { if (event.keyCode == 13) { $('[name="Search Button"]').click(); } }); </script>

 

0 Kudos
YUDI2
Apprentice

Re: Wrong results in search with enter button

On search button, after you filter the result, have you call  Refresh method on smartobject list ?

0 Kudos
toni_bezic
Rookie

Re: Wrong results in search with enter button

At first I did not call Refresh method on SmartObject list , but after your advice I did try it but it didn’t work. I got the same results. 

 

0 Kudos
Prineel
Scout

Re: Wrong results in search with enter button

Hi @toni.bezic,

 

I have an alternative solution:

Instead of using the script to both “click” (as in pressing the “Enter” on your keyboard) and “search”, why not just use it to “click” and use rules to search only:

 

36871ac2-af28-417e-9709-bf8421336cf7.png
This is how my form looks like, I have an item view that i use to search, and the list view to display data.
589f43a7-568b-4a34-987d-b0a1ec847ad3.png
On the form, this is the search button rule to get the listview data which I filter in the next image
c73002f0-a606-4aa9-bd8c-96ae3faebd7f.png
I filtered by what the textbox value contains
1e89e211-5758-4346-917c-533266e3b548.png
This is my item view, where i have the expression to press the search button when i press “Enter” on my keyboard
7487e388-729e-46c8-8147-cc5d084bd964.png
Literally just put the expression in the empty block as is, find the expression below
<script>
$('.SFC.SourceCode-Forms-Controls-Web-TextBox').keypress(function (e) {
var key = e.which;
if(key == 13)
{
var value = e.currentTarget.value;
$(e.currentTarget).SFCTextBox('option', 'text', value);
$('a[name ="NameOfYOurButton"]').click();
return false;
}
});
</script>

You just need to change the “NameOfYourButton” section with the name of your button lol. I got this script from : https://dudelisdev.com/2017/12/k2-smartforms-clicking-button-upon.html

 

If you need any explanation dont hesitate to ask. If you need a repro, just let me know what version of K2 you are using and I will try to upload a project you can deploy.

I hope this helps :).

 

Kind Regards

Prineel

0 Kudos