Array to Grid

Dear All,

I need to display the results of an array in a ScriptCase Grid/Grid Application. The array isn’t related to a database table so can’t just create a Grid Application from a connection. Is there a way to still display an array in a Grid and have the same functionality such as navigation and search?

Thanks greatly for any thoughts.


You COULD use an sqlite in memory database and connect the grid to it as far as I know. Since sqlite has pdo that should be doable. So you then should
insert the data into memory using sql statements and thus use a normal grid. I havent tested this with scriptcase but I know from delphi that this works…
Maybe this helps: (watch the To create a database in memory, append :memory: to the DSN prefix.)

Thanks for your thoughts. I’m trying to avoid writing records in this application, so hoping to find a way to create the grid directly from an array.

try this one, at least it works for me.

Create a table (temporarily) that matches your array. You only need it to design your grid, when you’re done you can drop the table.

In the onScriptInit event:

foreach($your_array as $row)
$inserts[] = “(”.$row[0].",’".$row[1]."’,’".$row[2]."’)"; // if you don’t have any string values you could also use: “(”. implode(’,’,$row).")",
$values = implode(’,’,$inserts);
sc_exec_sql(“CREATE TEMPORARY TABLE IF NOT EXISTS memtab (mem_id INT, r_date DATE, o_date DATE)”); //use the same names as in your grid’s SQL statement
sc_exec_sql(“INSERT INTO memtab VALUES $values”);

Run it.
Don’t pay any attention to an error on compile time that’s complaining about a missing table. :slight_smile:
There is no actual table in your db it only exists in memory at run time, visible to the current connection only and is dropped automatically.

See if it works.


1 Like

Thanks greatly, I’ll try this. Much appreciated!!