Multi-autosearch

Shows a textbox. When the user types in the textbox a list of search results is shown. The user can choose one value from the list or continue writing. The control only accepts values from the list of search results.

The control accepts multiple values.

Start value: Multiple comma(,)-separated values.
Return value: Multiple comma(,)-separated values.
Supported in: NewEdit Parameter page Multirow

SQL

SQL Call: Search (mandatory)

This call is made repeatedly as the user types into the textbox, and returns a list of search results for the entered value.

May modify database: No

Parameters

@TopN int
Max number of suggestions to return.

For better performance it is necessary to limit the number of suggestions sent from the database to the client.

Always use the exact value of @TopN in the TOP clause. Returning more values will cause an immediate exception. Returning fewer values when more values are present can cause unpredictable behavior.

You can use the Control height (rows) setting to control how many rows the list of suggestions contains.
@Value string
The text entered into the textbox.

Resultset: Search results

Table count: repeated exactly once
Row count: zero or more rows
Columns
<column with ordinal 1> mandatory string
Id value
<column with ordinal 2> mandatory string
Text shown in textbox.
<column with ordinal 3> optional string
Text shown in listbox.
Default: If not present the values from the second column are used.

SQL Call: Id lookup (mandatory)

Gets the values to show for the a comma(,)-separated list of ids.

This call is made first when the page is first loaded and every time the control's value is changed by a default value dependency or a JavaScript.

May modify database: No

Parameters

@Id string
Comma(,)-separated list of Id values to get the text for.

Resultset: Friendly values

Table count: repeated exactly once
Row count: zero or more rows
Columns
<column with ordinal 1> mandatory string
ID value. Must match one of Id values passed to the lookup procedure.
<column with ordinal 2> mandatory string
Text to show.

Default value

SQL Call: Default value

Retrieves the default value for the control.

May modify database: No

Resultset: Default value

Table count: repeated exactly once
Row count: exactly one row
Columns
<column with ordinal 1> mandatory string
The default value

Validation

SQL Call: Validation

This call is only made if there is a field validation set for the field info and the field has any content. Fields used in an editable grid do not use this call.

Live Validation

Performs field validation when the user leaves the field or one of its dependencies is changed, initial values set by default value and initial values in edit-mode are not validated.

Save Validation

When saving the validation runs server side if the field value has changed. A field value is considered changed if in new mode the value is anything other than NULL. In edit mode it is considered changed if it has a value that was not returned by the GetEditFields procedure.

May modify database: No

Parameters

@Value string
The value of the field, the procedure will not be called if value is NULL.

Resultset: Validation messages (optional)

Table count: repeated zero or one time
Row count: zero or one row
Columns
Error optional string
Error message to display. Blocks the user from saving.
Info optional string
Informative message to display. Does not block saving.
Warning optional string
Warning message to display. Does not block saving.

Examples

Multi-autosearch

Multi-autosearch works similar to a Textbox with autosearch with the main difference being that the Id lookup may contain multiple Ids.

CREATE PROCEDURE Example.MultiAutosearchTable_MultiAutosearch
	@Id				varchar(MAX) = NULL,
	@Value			varchar(max) = NULL,
	@TopN			int = 7
AS
BEGIN
	-- SQL Call: ID Lookup
	IF @Id IS NOT NULL
	BEGIN
		SELECT 
			T.MultiAutosearchTableId,
			T.MultiAutosearchTableName
		FROM
			(
				VALUES
					(1, 'Audi'),
					(2, 'Bentley'),
					(3, 'Chevrolet'),
					(4, 'Volvo Cars'),
					(5, 'Volvo Trucks')
			) AS T (MultiAutosearchTableId, MultiAutosearchTableName)
		WHERE
			T.MultiAutosearchTableId IN (SELECT I FROM SoftadminUtil.Number_ParseList(@Id));
		RETURN;
	END;

	-- If you need to be able to search for %, [], [^], _ - make sure you use the escape function below.
	SELECT @Value = ISNULL(SoftadminUtil.String_EscapeLikeWildcards(@Value), '') + '%';
	
	-- SQL Call: Search
	SELECT TOP (@TopN)
		T.MultiAutosearchTableId,
		T.MultiAutosearchTableName
	FROM
		(
			VALUES
				(1, 'Audi'),
				(2, 'Bentley'),
				(3, 'Chevrolet'),
				(4, 'Volvo Cars'),
				(5, 'Volvo Trucks')
		) AS T (MultiAutosearchTableId, MultiAutosearchTableName)
	WHERE
		T.MultiAutosearchTableName LIKE @Value
	ORDER BY
		T.MultiAutosearchTableName;
END;