Change the lookup table filter

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

Change the lookup table filter

Post by Andros »

In the lookup table filter is there any way to set a filter A when showing data in list/edit/view/add page and a filter B when opening the lookup modal?
For example I have a CustomerID which points to customers table.
When opening the modal I want to filter the selectable customers list on a specific AreaID (which can change sometimes).
But managing old records I want to clear the filter, because of mantaining historical variations. If I use the previous filter, the lookup table is empty.
How to do it?
I'd prefer to CHANGE the filter string, not clear it, for complex scenarios.
Thanx.
A


darkdragon
User
Posts: 148

Post by darkdragon »

Hi there,

I think you need to have a different approach, change the query for the lookup to include the historical values.

E.g. let's assume a scenario like yours:

  • You have a table of Customers, where some of them are active and some old entries are inactive.
  • The lookup table should contain all active records.

Then, in Lookup_Selecting event, change the UserSelect property by appending an union with the entry in your record:

if (fld.Name == "CustomerIDField") {
    UserSelect += " UNION select CustomerID, CustomerName where CustomerID = " + Convert.ToString(CustomerIDField.CurrentValue);
}

JuanJimenez
User
Posts: 1

Post by JuanJimenez »

Thanks for sharing, It also works for me


Post Reply