Following the exmple in Scriptcase WebSite i create a container application with a Control in one widget and a Grid Application in another one.
The problem is that the grid not always refreshes with the correct parameters. Like the variables are not being updated so the query does not change and neither the summary
I write this JavaScript code on a Button to refresh the Grid Application (Showing the Summary only) with the parameters set by the user.
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;
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
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]))
Thank you very much.
Regards,
Maxi