Emanuele Bonin - 2011-04-14

Hi All

I'm a newbie .
I built a Mask with a P4a_Table that have an Array_source populated by an ODBC query (i MUST read a DBF table)
Now the real problem is that i'm not able to change the query sended to the ODBC and so refreshing the table in the screen.

I tried to destroy and recalling the same Mask (changing a public WHERE variable) but don't work and i tried to load a new P4A_Array_source but don't work too.

SomeOne can help me ?

Below the example code that i tried:

<?php
class Queries_Mask extends P4A_Base_Mask
{
public function __construct()
{
parent::__construct();
$p4a = P4A::singleton();

if (!$p4a->connect)
$p4a->connect = odbc_connect("Database_VFP", "", "");

$a = array();

$query = "SELECT Codice, Descrizion FROM Tavola_DBF Where " . $p4a->where;

# query
$result = odbc_exec($p4a->connect, $query);
# I dati li etto su un array di appoggio
while(odbc_fetch_row($result)){
$Codice = odbc_result($result, "Codice");
$Descrizion = odbc_result($result, "Descrizion");
$a = array('Codice'=>$Codice, 'Descrizione'=>$Descrizion);

# Creo l'Array_Source
$array_source=$this->build("P4A_Array_Source", "array_source");
$array_source->setPk('Codice');
$array_source->load($a);
$array_source->setPageLimit(10);

// Define the grid table
$this->build("p4a_Table", "Main_Grid")
->setSource($this->array_source)
->setVisibleCols(array("Codice","Descrizione"));

$this->Main_Grid->disable();

$this->build("P4a_Button", "Button1")
->SetLabel("Bottone mio di \n pro\nva")
->implement("onclick", $this, "OnButtonClick");

$this->build("P4a_Sheet", "Sheet", 3, 4)
->anchor($this->Button1, 1 ,1)
->anchor($this->Main_Grid, 2, 2);

$this->display("main", $this->Sheet);

}

function OnButtonClick(){

$this->destroy();
$p4a = P4A::singleton();
$p4a->where = "Codice LIKE 'PROVA%'"
$p4a->openMask("Queries_Mask");

}
}
?>