SvySearch add Searchprovider in valuelist

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

SvySearch add Searchprovider in valuelist

Postby muhammadhammadmobin » Fri Jul 30, 2021 10:42 am

Hi all,
Hopefully, you all are doing well.
Can anyone help me with how can I use the custom value list in the search provider?
muhammadhammadmobin
 
Posts: 8
Joined: Mon May 31, 2021 7:08 am

Re: SvySearch add Searchprovider in valuelist

Postby paronne » Fri Jul 30, 2021 11:48 am

Hi,

you can use substitutions to search real values of a custom valuelist.

Code: Select all
var provider = simpleSearch.addSearchProvider(dataProviderID.toLowerCase());

var vlItems = application.getValueListItems(column.valuelist);
if (!vlItems.getMaxRowIndex()) {
   return;
}

// add valuelist substitutions
for (var index = 1; vlItems && index <= vlItems.getMaxRowIndex(); index++) {
   var vlItem = vlItems.getRowAsArray(index);
   provider.addSubstitution(vlItem[0], vlItem[1])
}


Please note substution won't be able to find values with partial matches (such as contains or starts with);
it can find only exatch matches.

e.g.
Valuelist values:
admin|1
basic|2
audit|3

user-type:admin // where "admin" is substituted to some stored value 1, will find all records having user type = 1.
user-type:adm // substitution doesn't have a match for "adm", it won'f find any user type.

Regards,
Paolo
paronne
 
Posts: 202
Joined: Fri Nov 02, 2012 3:21 pm

Re: SvySearch add Searchprovider in valuelist

Postby muhammadhammadmobin » Fri Jul 30, 2021 12:10 pm

paronne wrote:Hi,

you can use substitutions to search real values of a custom valuelist.

Code: Select all
var provider = simpleSearch.addSearchProvider(dataProviderID.toLowerCase());

var vlItems = application.getValueListItems(column.valuelist);
if (!vlItems.getMaxRowIndex()) {
   return;
}

// add valuelist substitutions
for (var index = 1; vlItems && index <= vlItems.getMaxRowIndex(); index++) {
   var vlItem = vlItems.getRowAsArray(index);
   provider.addSubstitution(vlItem[0], vlItem[1])
}


Please note substution won't be able to find values with partial matches (such as contains or starts with);
it can find only exatch matches.

e.g.
Valuelist values:
admin|1
basic|2
audit|3

user-type:admin // where "admin" is substituted to some stored value 1, will find all records having user type = 1.
user-type:adm // substitution doesn't have a match for "adm", it won'f find any user type.

Regards,
Paolo


Thanks, Paolo for your response.
It worked for me.

Marking this thread as RESOLVED.
muhammadhammadmobin
 
Posts: 8
Joined: Mon May 31, 2021 7:08 am


Return to Programming with Servoy

Who is online

Users browsing this forum: alasdairs and 10 guests