lookup modal search

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
darkdragon
User
Posts: 150

lookup modal search

Post by darkdragon »

Hello,

How can we change the default behaviour when searching in a modal dialog for a lookup field, of matching any letter(s) in Display Field(s)?
I'm interested in changing the behaviour to search for options that start with the typed letters?

So, instead of having this query

SELECT  TOP 100 [ID] AS [lf], [Title] AS [df], '' AS [df2], '' AS [df3], '' AS [df4] FROM dbo.Document_SendersValues WHERE [Title] LIKE N'%pro%'

to this one:

SELECT  TOP 100 [ID] AS [lf], [Title] AS [df], '' AS [df2], '' AS [df3], '' AS [df4] FROM dbo.Document_SendersValues WHERE [Title] LIKE N'pro%'

Regards.


MichaelG
User
Posts: 1110

Post by MichaelG »

You need to customize the "GetModalSearchFilter" function in "Models/src/Lookup.cs". For example, from:

string thisFilter = SearchExpression + Like(QuotedValue(keyword, DataType.String, dbid, "LIKE"), dbid);

to:

string thisFilter = SearchExpression + Like(QuotedValue(keyword, DataType.String, dbid, "STARTS WITH"), dbid);


darkdragon
User
Posts: 150

Post by darkdragon »

Thanks for the tip. Not an easy one solution.
Maybe an option in a future release, to switch between the two.

Thanks.


darkdragon
User
Posts: 150

Post by darkdragon »

Hi,

I'm reviving this topic one more.

In ANM2024, I see in lookup.cs this new static property ModalLookupSearchOperator.
Could you remove static from it? It works only if I initialize it Lookup<DbField>.ModalLookupSearchOperator = "STARTS WITH", therefore all instances of lookup fields are set-up.

Regards


MichaelG
User
Posts: 1110

Post by MichaelG »

You can still modify the static property in the Lookup_Selecting server event.


darkdragon
User
Posts: 150

Post by darkdragon »

Yes, I can modify it but this change is common to all instances of the class, instead of making the change per DBfield;
I want to have this approach:

	if (fld.Name == "assigned_to") {
		fld.Lookup.ModalLookupSearchOperator = "STARTS WITH";
	}

MichaelG
User
Posts: 1110

Post by MichaelG »

Try modifying the static property in your checking and adding an "else" case to reset the value.


Post Reply