The event “onSelect” allows you to select a row from the data table and manipulate the informations of that row.
For example, when you select a row, you can show it or manage it with data sources in a webform loader, or in a modal or a panel in the same webform.
if you look at my first screenshot, though (look at the expression pane screenshot), you can see that inside of the event, there is no information from the row.
Well, the onClick event of a datatable is slightly different from onSelect.
For example, clicking the header of a datatable will trigger the onClick event, but won’t trigger an onSelect event.
onSelect really is triggered when a row is actually selected after clicking in the datatable.
Another similar event, but different, is the datatable current element / onChange event, that is triggered every time the current element changes (such change can occur in another datatable of the same page, or by coding, not necessarily after a selection or click in the datatable).
what i’m trying to understand is what the purpose/use case is of onSelect, because at least as far as i can tell from my expression pane (see the first post), there isn’t any information to be gleaned from it.
Let’s suppose you have a datatable bound to an Entity Selection ES and a current element CE. The table just lists elements and you want to show details on another page. You can use onSelect to trigger a navigation event to the details page.
Another use case: you want to select elements in a list to add them in another list. Then you use onSelect to add the current element to another list.
As I said, onClick is different. It represents a user click anywhere in the component (here, a datatable). It will be triggered event if the user clicks on the table header, thus selecting nothing. Technically speaking, onClick does not guarantee that the datatable selected element actually took the value of the clicked row when it is triggered.
So if your event uses the datatable selected element as parameter, you’d rather use onSelect or datasource.onChange than onClick.
If your event does not rely on the datatable selected element, you can use onClick safely.
To summarize, those events are not triggered the same way:
component.onClick: triggered by a click anywhere in the component. The selected element (in case of a datatable or matrix or selectBox) may have changed or not, it has no importance.
datasource.onChange: triggered by the fact the datasource has changed.
datatable.onSelect or matrix.onSelect or selectBox.onSelect: triggered by the actual selection of a new element in the component.