For Datatables, they can be either populated with all entries of the linked datasource or with none. Ideally, I would like to have a context aware content, by giving a function that loads the entries depending on context, like from some values stored in a namespace. How to do that? Somehow, attaching a function to On Load of a webform containing the datatable, this does not work.
if i understand what you’re asking, you want to perform a query and use the result to populate your datatable, right?
i’m not going to write an example, if you’re asking something different than i’m answering.
if you want to do this at onLoad time (when the webform loads), then your context will have to already be set before you enter the form. what is your context, and where is it coming from?
once we have the details of your context figured out (because we have to be able to use it):
- create a function in the dataclass
- perform the query in the function, and return the entityselection.
- in the form, add an onLoad function event, and assign it to the function.
- in the same box where you assigned your function to the onLoad event, give the return value a name
- on the left, side, under form’s datasources add the name of your return value
- assign the return value as the datasource of the datatable.
Hi Mikeys, you’ve got me right.
What I’m trying next is moving the datasource from an adjacent webform to the “surrounding” webform. I have basically a webform that contains two webform loaders, which are used to display lists by default. The datasource that I need as an argument to execute a query is in one of the two “adjacent” webforms. I assume that may be an issue. In my current setup, the datasource is “undefined” upon calling the function.
if i understand you correctly, you have a webform that contains two loaders. inside of those loaders, the user is performing some action, which you want to propogate outward to your main form, right?
i have not tried that (hopefully the staff will respond with suggestions). just guessing (because i don’t know if the scope of the loader will allow this):
in the datatable in your loader, there will be two parameters for the datasource: the list, and the selected line, right? can you use the variable name that you use for the selected line a datasource in the parent form? then you would be, in effect, passing it out of the loader to the parent form.
the other thing that comes to mind is having an event fire in the loader, which links to a function, which either sets something in storage, that you can access in the parent form, or generates an entity in a dataclass.
I have solved the issue. The problem is, that during load time, I don’t have the context. When I have it, I have several options to refresh the contents of the datatable based on my search. I have it working now and I have now a better understsnding where to look in order to make things happen.
so, how did you solve it?
For once, I have a refresh button that populates the list with the results of my search. The other thing is, whenever I add something to the table, I call the search function to refresh the datatable. You have to get used to the concept that upon clicking a button you can perform several actions in a row.
the other thing to get used to is that the client is crippled, and everything has to be done on the server. this has always been a thing in low-code environments, so instead of writing object methods, you have a sequence of server calls.
where this issue really becomes obvious is when you are working with a select box.
if you use an array as a datasource (which, you kind-of have to, if you are going to support search, etc.), you can retrieve the value that the user selects within the component, using
$This.<propertyName>, and populate a text field component that is within the select box. BUT, if you want to extract that same text, and put it into a text field outside of the select box, you have to call the server, extract the property, and return it to the browser in a separate data source, which is bound to the field.
you can work with Session’s storage.
you can save in it your context (filters for example). and you can use an unload function to get the result base on it. and for each action (like searching / applying a filter) you need to update the storage.