Page 1 of 1
In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Thu Mar 07, 2024 6:19 pm
by Andros
Hi. I have two tables (it is an example, my needing is more complex):
reports - ReportID, Country, CustomerID...
customers - CustomerID,Name,Country, ...
In reports the CustomerID is setup with customers lookup table as usual.
When I ADD/EDIT a new report I want to select the Country, and then filter the customers lookup table by that country.
But I don't want to use dynamic selection, because, for example, I want to show the customer of that country and also the customers which don't have any country setup.
Is there any simple way to do this via javascript client code? The lookup_selecting filter is ok but it runs before outputting the page, while I need to customize the lookup table at runtime.
I can use the the client side events to intercept a field modification, and then what code can I use to rebuild the reports.CustomerID select2 list calling internal apis?
Re: In ADD/EDIT pages update Lookup Table SELECT2 control at runtime
Posted: Fri Mar 08, 2024 5:26 am
by crash
Use the filter lookup table settings.. there is an example when you set it up
Re: In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Fri Mar 08, 2024 5:03 pm
by Andros
but the "lookup table" filter is evaluated server-side at the page rendering time, and not every time the control is opened by the client, isn't it?
Re: In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Sat Mar 09, 2024 5:28 am
by MichaelG
Re: In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Tue Mar 12, 2024 3:35 pm
by Andros
Ok thank you. What about filling
Re: In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Tue Mar 12, 2024 3:36 pm
by Andros
Ok thank you.
In the example we can fill an INPUT control as written: $("#x_UnitPrice").val(row["UnitPrice"]);
What about filling select2 control?
Re: In Add/Edit pages update Lookup Table Select2 control at runtime
Posted: Thu Mar 14, 2024 7:19 am
by MichaelG
It should be similar. Just trigger the change event after update.