How do I get/set the CSS class of an object? #2
Replies: 1 comment
-
Hi Kirks, It's true that I haven't explored css management much. The solution you're considering, if I've understood correctly, presupposes that you load the form description, assign this or that class to objects depending on the context and then display the form based on the modified description. I think this is possible, but I'm not convinced that you need to cache the form in the Storage. While caching could improve performance, especially in scenarios where a subset of forms is frequently accessed, it might not be necessary for all projects. If reading the JSON description is quick and your forms are not extremely complex, caching might not provide a significant performance boost. Notice that the formDelegate class already loads the JSON description of the form: // Keep the form definition
var $file : 4D.File
// Component forms have priority
ARRAY TEXT($forms; 0x0000)
FORM GET NAMES($forms)
If (Find in array($forms; This.currentForm)#-1)
$file:=File("/SOURCES/Forms/"+This.currentForm+"/form.4DForm")
Else
$file:=File("/SOURCES/Forms/"+This.currentForm+"/form.4DForm"; *)
End if
If ($file.exists)
This._definition:=JSON Parse($file.getText())
End if |
Beta Was this translation helpful? Give feedback.
-
The only thought I'm coming up with is to read the form.4DForm file which is a bit heavy if we're doing UI with classes at scale.
I suppose I could have a LOAD FORM method that reads the form.4DForm file and returns the form object and caches it in Storage. The cache would only capture the forms actually used so it would be efficient in that in a large database (say 1000+ forms) a user sessions may access 50 or even 100 of them, but not all.
This scheme would allow user preferences to be applied to individual forms as well as access and change CSS settings on objects.
Beta Was this translation helpful? Give feedback.
All reactions