Dashboard and parameters: One Ring to Rule Them All?

[LEFT][SIZE=13px]Hello, everyone. Back in the days of Scriptcase 8 I finally got a dashboard to run with a control app inside a “master” widget, and other widgets containing grids to show different tables data. In the control app you can select a year, and the grids updates to show data for this year. This was done by using javascript to reload each grid inside their respective widgets, with the year as a parameter. (Every grid has a WHERE sentence using a global variable).[/SIZE][/LEFT]

[LEFT][SIZE=13px]​But I can’t get this to work in Scriptcase 9.[/SIZE][/LEFT]

[LEFT][SIZE=13px]​Please, don’t tell me to look at the “Parameters in container” sample from SC site. It’s an old sample and works only in SC8, not in the new Dashboard app from SC9.[/SIZE][/LEFT]

[LEFT][SIZE=13px]​Using the demo in the “Samples” project, I found very simple to link one grid to another: you just create the two grids, a field link between them, and create a widget for the first grid. Scriptcase creates the second widget for you if you choose “Automatically create target widget” in the properties of the first. When running, clicking on the field link updates the second grid. So far, so good.[/SIZE][/LEFT]

[LEFT][SIZE=13px]​But what if you need to update more than one widget? I like to show and update three related grids when clicking the link.[/SIZE][/LEFT]

[LEFT][SIZE=13px]What I need: one “master” widget with a control app in it, and three other widgets with grids (could be charts, too) that updates when I made a change in the control in the “master” widget.[/SIZE][/LEFT]
[LEFT][SIZE=13px]​Alternatively, one “master” widget with a grid in it, and three other widgets with grids that updates when I select a record o click in a field link in the grid “master” widget.[/SIZE][/LEFT]

[LEFT][SIZE=13px]Any ideas or suggestion will be highly appreciated![/SIZE][/LEFT]

Partially Solved:

​I found how to update widgets from the control app in my “master” widget, when the user presses the “OK” button:

​First I designed my dashboard, putting every widget with their corresponding apps. Run the app and examine the HTML generated. Use the name of each widget to locate the iframe and write down the iframe names.

​STEPS:

​1. Create every app you will need, set the WHERE sentences to use one or more global variables, and set them to be “Session” only.

  1. Create global variables (one for each parameter you will need in the WHERE sentences of your dependants applications), in your control application. In my case I just need a year parameter, so one variable was enough.

​2. In the control app onValidateSuccess event, set the value for each global variable. In my case I simply put the year number (from a select field) into the global variable. Something like this:

[fkPeriod]={fkPeriod};

​3. In the control app onLoad event, use an echo to put the javascript code that set the href and reload each of the iframes. The href must be the relative path to the app inside the widget you want to refresh.

echo "<script>
parent.document.getElementById('id-iframe-1').contentWindow.document.location.href = '../chart_da_presupuesto/chart_da_presupuesto.php';
parent.document.getElementById('id-iframe-1').contentWindow.location.reload(true);
</script>";

​Ready! If you press the “OK” button in your control app, the other widget content will reload.

But I still looking for how to do this from a grid link.

In a grid you might be able to use the same method, but enclose the javascript code inside a function (a javascript funcion, say you called it

 tfertilsfunction()

). Then in scriptcase’s event “onRecord” of the grid app, create some html for the content of a column like:


{action-column} = "<button onclick="tfertilsfunction()">Click me</button>";

So the grid has a button in your column “action-column” and when the buttons is pressed, the javascript is called.