Hi everybody,
In my program, I need to create fields at runtime related to database content.
In my database, I have the detail of my UI : type of field (TEXT_FIELD, COMBOBOX…), value of the field, values for the combobox.
I succeeded to create the form and its controls but I don’t understand how to save values in database if the user types in.
I don’t know in which event I can do this (maybe in onRecordEditStop ?).
As it is difficult to explain all the structure, i join my solution in the post.
If someone can help me…
Thanks !
slnDynamicField.servoy (78.7 KB)
I just glanced at your code quickly. Instead of binding your fields to form variables, why not bind them directly to the database fields? Then Servoy will just take care of saving the data back to the database per normal behaviour.
Hi Bobby,
I will quickly explain the DB model :
In “dynamic_field”, there is the detail of the field I want to display (even empty).
Ex : “name field”, “description field”, “Occupation field”.
In “client_dynamic_field”, there are the values of the Dynamic field for a client.
Ex : “OWEN”, “Patrick”.
In “dynamic_field_list”, there are items for COMBOBOX field. These values will be bound to a valuelist at runtime.
Ex : “Developer”, “Scrum master”, “Analyst”, “DBA”.
Then if the table “client_dynamic_field” is empty, I want to have 3 empty fields on screen. So, at this time, I have 4 fields and no row in my database.
So, I don’t think I can bind fields to database fields. If you think it is possible, I’d like to know how, because I began servoy for 4 weeks ago.
I will try to do that and post what I find.
Thanks !
I’m doing that right now… so I know it’s possible ![Wink :wink:]()
Set your solution model form’s data source to the table you are referencing…
_jsForm.dataSource = “db:/someServer/someTable”;
Get your field(s)…
var _jsEntryField = _jsForm.getComponent(“someField”);
Set your dataprovider ID to a field in the table…
_jsEntryField.dataProviderID = “some_database_field”; //You can also use relations
If that table is empty, you’ll need to create a record in that foundset.
forms.someForm.foundset.newRecord();
That’s the quick two minute explanation…
Hi,
Does it mean it will create empty rows in the DB each time the form displays ?
I finally succeed to do what I want, and everything is dynamic.
The code is attached.
slnDynamicField.servoy (13 KB)