If you have >5 seconds loading-delay when using
AppGiniHelper.DV.getField("FIELDNAME").toStatic()
on a lookup-field, try passing null
as 1st
and true
as 2nd
parameter:
Code: Select all
AppGiniHelper.DV.getField("FIELDNAME").toStatic(null, true);
Problem
Recently I was wondering about loading delay in DV. Duration-measurement from page-load till AppGini hided the "loading"-indicator was >5 seconds:
Loaded in 5.159s
---
After narrowing down my javascript code I figured out the delay came from just one line of code:
Code: Select all
// file: hooks/TABLENAME-dv.js
//...
AppGiniHelper.DV.getField("type_id").toStatic();
//...
That
toStatic()
-function converts a lookup field......into a (readonly) display field:
(Note: I'm using this a lot for example for denying changes after initial insert or for keeping the relation to the parent record)
The function automatically waits for lazy-loaded lookup-controls. This means usually we don't have to care for the field-type but just call the function and let the helper do the rest.
Obviously, this leads to delays on page-load, so I did some research.
Reason
There is one problem: Before hiding the "loading"-indicator (and showing the detail view), AppGini waits for certain HTML elements. In this case it waits for the lookup-control, identified by classname
.select2-container
. If we change our lookup to a static-control, this .select2-container
never appears. This means AppGini waits until timeout after 5 seconds. And this brings the delay.Solution
In these cases we can simulate existence of such a control and therefore let AppGini find a (hidden) dummy-element instead of waiting for timeout.
Fortunately, I've alread prepared the code for handling such issues. The only thing you have to do is pass
true
as 2nd
parameter like this:Code: Select all
AppGiniHelper.DV.getField("FIELDNAME").toStatic(null, true);
Loaded in 0.263s
Summary
What I have learned today: when using
.toStatic()
on a lookup field, pass true
as 2nd
parameter.