NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Rene Simons on September 28, 2019, 01:39:42 AM

Title: Javascript filter of a browse
Post by: Rene Simons on September 28, 2019, 01:39:42 AM
Hi,

When building a browse for e.g. a phone app, the filtering is to be client side.
In the documentation an example shows a javascript statement like

'return record.paid ==1 ? recordOk : recordFiltered'

2 questions:
Rene
Title: Re: Javascript filter of a browse
Post by: DonRidley on September 30, 2019, 02:02:15 AM
Hello Rene,

Quoted in the JS itself?  No.

I'm not a JS expert but I'm fairly sure you could call a function and get that return value. 

Don
Title: Re: Javascript filter of a browse
Post by: Rene Simons on September 30, 2019, 03:20:06 AM
Hi Don,

Thanks for your reply.
ad 1: That would be nice in case you have a more complicated (but not too complicated) filter.
ad 2: I mean in the template field where the JS-filter must be typed in.

René
Title: Re: Javascript filter of a browse
Post by: DonRidley on September 30, 2019, 05:42:53 AM
ad 2: I mean in the template field where the JS-filter must be typed in.

Yes sir.  That needs to be in quotes. 
Title: Re: Javascript filter of a browse
Post by: Bruce on October 09, 2019, 02:41:44 AM
Hi Rene,

yes, you can call a JavaScript function here. The function should return RecordOk or RecordFiltered.

here's an example from the CIDC training app;

function filterMessages(){
   if ( (database.messages.record.fromuserguid == database.friends.record.friendguid) ||
       (database.messages.record.touserguid == database.friends.record.friendguid) ){
      return recordOk
   } else {
      return recordFiltered
   }   
};


Cheers
Bruce
Title: Re: Javascript filter of a browse
Post by: Rene Simons on October 09, 2019, 05:25:43 AM
Bruce,

Nice! Thank you.

René