On Page Load Variable set.

George Amend shared this question 6 years ago
Answered

How do you get the prototyper to select the elements in the first cell in a data grid on page load? In other words, when the page loads I want the data in the first record associated with the data grid to populate the associated variables.

Comments (1)

photo
1

Hi George,


Your question intrigued my curiosity!


Setting the value of a variable with a row on page load would be achieved with a page load event from the row itself -> setValue(variable, row).


Q: So how do we achieve that only the first row sets the value?


A. Use a condition (if first_row then setValue)


Q: How do we identify the first row?


A1: Use an identifier for each row, thus (if id==1 then setValue). It works. However this approach not only requires an extra field in the data master, but doesn't work if the first row has e.g. id=5.


A2: Use the function DataCount to determine how many rows the data grid has. This would have been nice, unfortunately all records are inserted at once.


A3: Use an extra counter variable, which is incremented by each row, thus (if counter==1 then setValue) will determine that the first row is currently in use. This approach requires some maintenance, you would need to initialize the counter and optionally reset the counter if it's to be used more than once. But works!


I have set up an example prototype, which I could send to you. Please contact jim.support [at] justinmind.com