Populate Select boxes on the server side

Post Reply
bkonia
User
Posts: 141

Populate Select boxes on the server side

Post by bkonia »

When populating a lookup field on an edit form, the selected value and the entire options list is known before the page loads, so why is the user subjected to the extra wait time for Ajax requests to populate Select boxes? The main page request is blocking, so this results in unnecessary wait time for the user. Instead, Select controls should be populated on the server side. Ajax requests should only be used in response to the user changing something AFTER the page loads. For example, if the user changes the value of a parent select control, that would obviously require any dependent controls to make Ajax requests. Also, since it initially only populates the control with the selected record, when the user clicks on the control, it has to make yet another Ajax request to fetch all the options.

PHPMaker used to work as I described. However, a few versions back, it transitioned to populating lookup controls from the client-side. I understand this makes it easier to develop custom UIs, since everything works from the same client-side API. In theory, this may be a better approach, but with a real-world application, every millisecond counts, so it's critical to minimize the number of requests per page, as each request adds overhead.

This situation could be solved by providing a checkbox in the Edit Tag property sheet, called Prepopulate from server side. When this checkbox is enabled, it would load the full options list on the server side, so no Ajax request would occur during the page load, and no Ajax request would occur when the user clicks on the control. If it's a dependent control, then of course it could still update via Ajax, when the user changes the value of its parent control. This option would give the developer the choice of how to render the page, either entirely on the server side, or partially on the client-side, depending on how the developer wants to handle it.


bkonia
User
Posts: 141

Post by bkonia »

As a followup to this request, I've discovered there are two field properties, which can be set in the Page_Loading event, to customize the lookup behavior.

$this->someField->UseLookupCache
$this->someField->LookupCacheCount

I believe if these properties were available in the UI, under the Edit Tag property sheet, that would solve the problem, as we'd be able to customize the lookup cache behavior in the UI, for each field that uses lookups.

Additionally, I'd like to request in the Table settings, an option to set the lookup behavior for each page type. For example, under the Add Page section, there could be a Use lookup cache property, that would enable the lookup cache for the Add page. Similarly, the same setting could be included in the Edit Page, List Page, Multi-Update Page, and Search Page sections. Thus, we'd be able to customize the lookup cache behavior at the page level, and for each field on the page.


Post Reply