Following the exmple in Scriptcase WebSite i create a container application with a Control in one widget and a Grid Application in another one.
I write this JavaScript code on a Button to refresh the Grid Application (Showing the Summary only) with the parameters set by the user.
[B]url = "../COMPARATIVO_VENTAS_SUCURSAL/COMPARATIVO_VENTAS_SUCURSAL.php?desde='" + document.getElementById('id_sc_field_fecha_desde').value + "'&hasta='" +
document.getElementById('id_sc_field_fecha_hasta').value + "\'";
alert(url);
parent.document.getElementById('id-iframe-widget2').contentWindow.document.location.href = url;[/B]
In the ScriptInit Event of the Grid Application i have this code.
if (isset($_GET['desde'])) {
$DESDE = $_GET['desde'];
[BEGIN_DATE] = $DESDE;
} else {
[BEGIN_DATE] = ' DATEADD(DD,0,DATEDIFF(DD,0,GETDATE())) ';
}
if (isset($_GET['hasta'])) {
$HASTA = $_GET['hasta'];
[END_DATE] = $HASTA;
} else {
[END_DATE] = ' GETDATE() ';
}
And this is my query
[B]SELECT
R.BRANCH AS SUCURSAL,
R.AMOUNT AS MONTO,
DATEADD(DD,0, DATEDIFF(DD,0,R.DATETIME)) AS FECHA,
DATEPART(YEAR, R.DATETIME) AS ANO,
CONVERT(varchar(5),r.datetime,103) AS DIAMES
FROM RETAIL R
WHERE (DATEADD(DD,0, DATEDIFF(DD,0,R.DATETIME)) BETWEEN [BEGIN_DATE] AND [END_DATE])
OR (DATEADD(DD,0, DATEDIFF(DD,0,R.DATETIME)) BETWEEN DATEADD(YY,-1,[BEGIN_DATE] ) AND DATEADD(YY,-1, [END_DATE]))[/B]
The problem is that the first time i click the button the iframe reloads the content, receives the parameter but the grid is not updated.
If i click the button one more time everything works fine.
I check with Echo function that parameters are arriving well both times i click the button.
Any idea what can i do?