Some of you may have noticed that if you use the onKeyUp event on an xpage and do a partial refresh of a view or repeat, if you type at a quick pace it stops updating after about two characters, thus giving you an incorrect filter.

At first i thought this was an Xpages issue, but after some google searches noticed it was an ajax issue. I found some code and modified it it to work in the viewpicklist custom control that i wrote.  Here is what i am now using for the view picklist control.

First i added an output script to the control. This delays the refresh until a user has stopped typing for 1/2 second.

 

<xp:scriptBlock id="scriptBlock1">
		<xp:this.value><![CDATA[${javascript:"var count = 0; function doMyRefresh()" +
"{   count = count+1;   setTimeout('doMyRefreshGo('+count+')',500);}; " +


"function doMyRefreshGo(currCount)" +
"{ if(currCount == count){ count = 0;" +

'XSP.partialRefreshPost("#{id:' +compositeData.dialogID + "table"+ '}", {' +
 '   onComplete: function() {'+
  '  }' +
'});' +

  
'}}'}]]></xp:this.value>
	</xp:scriptBlock>

 

 

Then i changed the onKeyUp event to call doMyRefresh() in csjs, with no update or any SSJS.

Now to do this where you dont have to compute the refresh id like in the viewpicklist custom control, its a little easier.

<xp:scriptBlock id="scriptBlock2">
		<xp:this.value><![CDATA[var count = 0; function doMyRefresh()
{count = count+1;   setTimeout('doMyRefreshGo('+count+')',500);};

function doMyRefreshGo(currCount)
{if(currCount == count){ count = 0;
XSP.partialRefreshPost('#{id:yourid}', {
onComplete: function() {
}
});
}};]]></xp:this.value>
	</xp:scriptBlock>
 

7 Responses to Xpages: Fast typing – Filtering a view – a Problem, and a fix

  1. Steven Rieger says:

    Can I ask, do you have a sample that shows how to update a view with type ahead? I can’t seem to figure this out.

    I have it working using an edit field and a search button but I really want to update the view with type ahead.

    Thanks for your help!

    STeveR

    • Mark Hughes says:

      if you download the viewpicklist you can see how it is done. Th basics are in the view datasource you put the scoped value of the typeahead field into the key paremeter or the startkey param, which are only found in the all properties section of the datasource. Then on key up use the scipt i have above, replace your refresh id instead of mine. make sense?

  2. Mudit says:

    Hi,

    Trying something similer, Please help.

    I need to enter some text in a inputText field and want that my view panel documents soreted according to that key.

    Ex:- if i write a in my text field then first column of my view panel show me all documents started by a and if i write ax then all documents will sort by ax.

    Please help….

  3. ipad cover says:

    The protective case has been made of a tight fitting anti-slip material that feels really great in your hand, it also means it’s less likely to slip from your hand or plummet from the edge of the table. OK, let’s start with handset style,
    all of the devices come with different casings, the Black – Berry Bold
    9780 and the Curve 8520 have classic Blackberry bar form casings complete with
    full QWERTY keyboards, whereas the Black – Berry Torch 9800 has a slider
    form casing with slide out QWERTY keyboard and a touch screen.

    i – Pads are now the in-thing and having one is a status symbol.

  4. Also, take a tiny to impediment out the certificates of the vender. This will keep you away from any scammer luggage. If the online company offers you a profitable quantity for your coin and they have been in the craft for a while, with a unintermitted proceeds pour and few official complaints, then you are in for the concordat of your life. In a stock that sells low-priced A Lange Sohne Duplicate Watches, you will be able to buy a specifical time-keeper that is also a bit of ? la mode bijoutry and a classy same as accessary, all under a distinguished brand name.

  5. Wow, fantastic weblog layout! How lengthy have you ever been blogging for?
    you make blogging goance easy. The total look of your wweb site is magnificent,
    let alone the content material!

    Look at mmy site … Laminate (http://www.pendock.co.uk/)

  6. There also exists a smaller garden that houses baby turtles rolling around in its small lake.

    Top Spain City Breaks Barcelona, Madrid, Valencia, Palma de
    Mallorca, Ibiza Town, Seville, Granada, C. If you do go mad the queue, the
    path vendor opposite sells beer.

Leave a Reply

Your email address will not be published. Required fields are marked *