Grid Multi-Select with Run Button returns wrong values

Hi,

I’ve a grid with a run button to run a custom script on the selected rows.
I’ve followed this tutorial [1] and while it works fine the first time I click on the run button, if I press it a second time it gives me some values that are not even in my table.
This is what I did :

OnScriptInit


[total_chked] = array();
[i]=0; 

Run Button on record


$arr=[i];
[total_chked][$arr]={ident};
echo {id}."..".{ident}." ***************<br/>";
[i]++;
echo {id}."..".{ident}." ***************<br/>";

Then if I run my app and I select the first row that have :
id = 3 | ident = 97422AK0358

The result of the onrecord event is :

First time:
3…97422AK0358 ***************
3…97422AK0358 ***************

Second time (same row selected, i’ve just press again the run button):
71…97405AB0040 ***************
71…97405AB0040 ***************

What is really weird is the id 71 exists in my database with the ident 97405AB0040.
But this value is not even in my table.

Please, could you tell me if I did something wrong or if it is really a bug ?
And, could you please explain the [total_chked] [i] [arr_vl] variables. I don’t really understand to what they refer.

Thanks

Arnaud
[1] http://www.scriptcase.net/samples/tutoriais/grid/grid45.php

Please, could you tell me if I did something wrong or if it is really a bug ?

You have to reset your variables after processing the records in the onFinish event of the button.

[total_checked] = array();
[i] = 0;

And, could you please explain the [total_chked] [i] [arr_vl] variables. I don’t really understand to what they refer.

[total_checked] and [arr_vl] are actually the same array, they (NM) just totally messed up the names.
[i] is just a counter, for what reason (in this case) is beyond me. You don’t need it you just do (Button - onRecord):

[total_checked][] = {ident};

jsb

Hi jsbinca,

Thank you for the explanation. I really appreciate.
Unfortunately, even if I reset the variables the result on the second time is still incorrect.
I’ve tried something very simple and on the onRecird event I have :
echo {id_dossier};

The first time the id is the good one, but not for the next ones. It still gives me some ID that are not even listed in my grid.

Thanks

Arnaud