how to display a dataset column in a grid field

hello, in my grid im trying to do some modifications to the fields and i need a field to display something i get through the sc_lookup macro and store it in a dataset. how can i do this?
i tried doing this:
{myField} = {Dataset};
but that didnt work.
{myField] = {Dataset[0]} doesnt work because this just gives me the first row.

thanks

I what way is the grid record linked to your lookup? so Is your lookup using a field from the grid to get the dataset result?

i pass the parameter for the table and fields for the lookup from another application

but no relation between the 2 tables? Is the result of the dataset always the same number of records? Should the first row in the dataset be pasted in the first row of the grid, and so on? Or is there another value to check on?

its not always the same number of columns so if i have less columns than fields ihide the extra fields

for example in the application i have fields1 through 10 and i need a table that has 5 columns, i want those columns to be displayed in the first 5 fields and hide the rest(i hide them with sc_field_display)

edit: sorry i accidentaly made two posts instead of one

{myField0] = {Dataset[0]}
{myField1] = {Dataset[1]}
{myField2] = {Dataset[2]}
{myField3] = {Dataset[3]}
{myField4] = {Dataset[4]}

{myField10] = {Dataset[10]}

this will give you 10 columns linked on a dataset.

But this will give an error when eg only 4 rows in your dataset exists.

Any i find this a strange way to use a GRID. Nomally you and table linked to the GRID and filled with data.

​​​​{myField0} = {Dataset[0][0]};
{myField1} = {Dataset[0][1]};

{myField9} = {Dataset[0][9]};

If you want to show each record from the Dataset in a different field in the grid.
But I’m not sure that’s what you want.

i tried this, it only displayed “array” in every entry in that field

this displayed the same record on every entry in the field.

show us the sql string you use for the lookup

its a simple select:
$sql = “select * from {hojxdoc}”;
{hojxdoc} is a table

i use * because i dont know how many fields the table contains

Then
{Dataset[0][0]}; //should give you the first COL of the first ROW
{Dataset[0][1]}; //SECOND COL 1ST ROW

{Dataset[1][0]}; //1ST COL 1ST ROW
{Dataset[1][1]}; //2ND COL 1ST ROW

Up to you to link the correct COLUMN to your {myField0}, {myField1},{myField2},…

{myField0} = {Dataset[0][0]};

You can link multiple datasets to one field

{myField0} = {Dataset[0][0]} . ' - ' . {Dataset[0][1]};

that will just display every column from the first row in one field unless i am mistaken
my issue is this, lets say my dataset looks like this:

Dataset:
1 a A
2 b B
3 c C

if i do this: {myField0} = {Dataset[0][0]} . ’ - ’ . {Dataset[0][1]};
the grid will look like this:
field0 field1 field3
1-a x x
1-a x x
1-a x x

ofcourse it will always show the same value since you use Dataset[0][0]

in order to get second row from dataset on second row of the grid you must change Dataset[0][0] to Dataset[1][0]

use a counter variable to count number of records and use this value in the onrecord event

so something
like

onscriptinit
$counter=0;

onrecord event
Dataset[$counter][0]
$counter++

thank you! that Works very well, now im having trouble with errors that the variable counter does not exist for some reason, even though its working so it clearly does exist, but ill figure it out, thanks