How to show search suggestions in a text field during typing

How to show search suggestions in a text field during typing? I tried a field using the property “displayType” “TYPE_AHEAD” and then I applied a valuelist with table values “name” from a database. This only works for the beginning character. If I want to search for a string “n.v.” that is not the beginning of a word, this doesn’t work.

Change your valuelist so it is based on a global method, in that method you can implement it however you want.

The way I was able to do this was by attaching a global method to the valuelist. Here is a sample in which I split the search string on spaces:

function getDataSetForValueList_vlUserManagement_username(displayValue, realValue) {
	/**@type {JSFoundSet<db:/sample/table_one>} */
	var fs = databaseManager.getFoundSet('db:/sample/table_one');
	/** @type  {JSDataSet} */
	var result = null;
	if (displayValue == null && realValue == null) {//field is empty
		fs.loadAllRecords();
		fs.sort('column_one asc')
		result = databaseManager.convertToDataSet(fs,['column_one','column_two']); //[display value, real value]
	} else if (displayValue != null) {//field has text
		var searchText = utils.stringTrim(displayValue);
		var searchArray = searchText.split(' ');
		if (fs.find()) {
			fs.column_one = '%' + searchArray[0] + '%';
			fs.search();
			for (var a = 1; a < searchArray.length; a++) {
				if (fs.find()) {
					fs.column_one = '%' + searchArray[a] + '%';
					fs.search(false, true);
				}
			}
		}
		fs.sort('column_one asc');
		result = databaseManager.convertToDataSet(fs,['column_one','column_two']);
	}
	return result;
}

Joas:
Change your valuelist so it is based on a global method, in that method you can implement it however you want.

My intention was, how can I do it in the global method. ;)

peterbliskavka:
The way I was able to do this was by attaching a global method to the valuelist. Here is a sample in which I split the search string on spaces:

function getDataSetForValueList_vlUserManagement_username(displayValue, realValue) {
/**@type {JSFoundSet<db:/sample/table_one>} */
var fs = databaseManager.getFoundSet('db:/sample/table_one');
/** @type  {JSDataSet} */
var result = null;
if (displayValue == null && realValue == null) {//field is empty
	fs.loadAllRecords();
	fs.sort('column_one asc')
	result = databaseManager.convertToDataSet(fs,['column_one','column_two']); //[display value, real value]
} else if (displayValue != null) {//field has text
	var searchText = utils.stringTrim(displayValue);
	var searchArray = searchText.split(' ');
	if (fs.find()) {
		fs.column_one = '%' + searchArray[0] + '%';
		fs.search();
		for (var a = 1; a < searchArray.length; a++) {
			if (fs.find()) {
				fs.column_one = '%' + searchArray[a] + '%';
				fs.search(false, true);
			}
		}
	}
	fs.sort('column_one asc');
	result = databaseManager.convertToDataSet(fs,['column_one','column_two']);
}
return result;

}

Thanks, that was what I needed, but what is the “realValue” for?

When you create a valuelist, there is the option for “Show in field / list” and “Return in dataprovider”. “Show in field / list” is the displayValue, “Return in dataprovider” is the realValue. They can be the same column, but in my case I am using a string column for the display value and a UUID column for the realValue.