Page 1 of 1
lookup modal search
Posted: Thu Jul 27, 2023 10:28 pm
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.
Re: lookup modal search
Posted: Fri Jul 28, 2023 6:22 am
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);
Re: lookup modal search
Posted: Fri Jul 28, 2023 9:31 pm
by darkdragon
Thanks for the tip. Not an easy one solution.
Maybe an option in a future release, to switch between the two.
Thanks.
Re: lookup modal search
Posted: Mon Mar 11, 2024 2:17 am
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
Re: lookup modal search
Posted: Mon Mar 11, 2024 8:08 am
by MichaelG
You can still modify the static property in the Lookup_Selecting server event.
Re: lookup modal search
Posted: Tue Mar 12, 2024 12:17 am
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";
}
Re: lookup modal search
Posted: Tue Mar 12, 2024 7:17 am
by MichaelG
Try modifying the static property in your checking and adding an "else" case to reset the value.