Global variable = value of a field in record grid selected

I would like to pass the value of a field of the selected row in the grid to a variable.
Each time I click on a row that becomes the selected one, the value of a field updates the variable.
It’s possible?

you can use ajax event on click and set in the event the variable to the field value

but the ajax event on click can only be set on the field but not on the entire row