This topic is locked
[SOLVED]

Taking a value from the list page and using it in code snippet.

8/28/2024 10:20:14 AM
PHPRunner General questions
K
kenan_almata author

Hi everyone,

Is it possible to take a value of a field on the list page and use it in the code snippet?

İn this example, I want to take the value of countryid and display it from COUNTRIES_snippet at the end of the row for each records.

Schoolid, schoolname, countryid, schoolwebsite, COUNTRIES_snippet

in COUNTRIES_snippet
echo $data["countryid"];

What should I write in COUNTRIES_snippet?

Thank you so much.

img alt

Sergey Kornilov 8/28/2024

Code snippets are executed once on the page load and cannot access grid data. You need something that will execute multiple times, once for every grid row.

Start by reading this article:
https://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/

K
kenan_almata author 8/28/2024

Thank you for your response.

mbintex 8/28/2024

Proposal:

  • have a virtual field in your SQL like

' ' as countries_snippet

place that in your table and have a custom view code for the field. With that you can not only design how this field looks like, but you can also work with all values from all other fields.

If you use your virtual field in Edit and Add screens don´t forget to

Unset

that virtual field before saving.

K
kenan_almata author 8/30/2024

Thank you.

I just wanted to understand in a code snippet, how to get a value of a field from the grid data and Mr. Kornilov said it is impossible.