List View Control Filtering not updated, when changing Filter Text Box value by javascript

  • 28 September 2017
  • 3 replies
  • 14 views

Badge +3

Dear Community, 

I have a form where I use the list view control. The filter for this control is based on another text box.

When I enter the value manually AND PRESS ENTER, then the filter works.

But I'm adding the value by a Javascript and then it doesn't fire the filter. 

208647_pastedImage_1.png

The script looks like this and is called in the formula of a calculated value. It does add the value to the text box as expected.

function UpdateTextBox(myValue){
   NWF$('#'+SpecNrFilterTextBox).val(myValue);
return;}

When I add another line like 
NWF$('#'+SpecNrFilterTextBox).trigger("change");

it ends up in an endless refresh loop. Also .trigger("blur") does not work for me.

Any help would be highly appreciated.

Thanks and best regards,

Rubi


3 replies

Badge +5

Hi Rouven Bilgeri,

took longer time to solve this problem than I anticipated, but after I traced the root cause it was such a simple thing to fix happy.png 

I assume you are setting your text field which supposed to serve ur list view control in the Jquery page load event. I noticed that when we use look up function on the Nintex form it is triggering page load event also hence re-executing everything that we write in ready function. To prevent that infinite loop all I had to do was put extra validation of checking if the control is actually empty or not. Ola the problem solved no more infinite refresh issue.

this is how I re-wrote your logic 

NWF.FormFiller.Events.RegisterAfterReady(function () {

var _Title = NWF$("#" + varTitle)
if(_Title.val()=="")
{
_Title.val("ENT");
_Title.triggerHandler("change");
}

});

I understand that you are setting this field on calculated field change event, event there you may have to add some extra logic to not reset again and again like keeping copy of it in a hidden field and checking etc. 

I hope this helps you in solving your project.

Badge +3

Dear Jaya Borra, 

thanks a lot for your input - you guided me into the right direction. 
I could solve my problem with a simple condition too. 

function UpdateTextBox(myValue){
if(NWF$('#'+SpecNrFilterTextBox).val() != myValue){
   NWF$('#'+SpecNrFilterTextBox).val(myValue);
   NWF$('#'+SpecNrFilterTextBox).trigger("change");
return;}}

So now it does only trigger "change" if the value is not already the expected one.

Best regards,

Rubi

Badge +7

Thanks so much for this post, Rubi! This is the solution I was looking for. happy.png

Kind regards,

Yvette

Reply