Hello, I have two view:
View def
I show a grid Apparecchiature
View manutenzioni
I show a grid with a list of Manutenzioni for each Apparecchiatura on the left, and a form with detail of Manutenzione on the right
function doOnLoad() {
...
...
myToolbar.attachEvent("onClick", function(id) {
switch(id) {
case "apparecchiature":
myLayout.cells("a").showView("def");
view = "def"; //per pulsanti aggiungi e cancella
break;
case "manutenzioni":
myLayout.cells("a").showView("manutenzioni");
view = "manutenzioni"; //per pulsanti aggiungi e cancella
break;
...
...
// Def view
attrezzatureLayout = myLayout.cells("a").attachLayout("2U");
ViewAttrezzature();
view = "def"; //per pulsanti aggiungi e cancella
...
...
// Global view "manutenzioni"
myLayout.cells("a").showView("manutenzioni");
manutenzioniLayout = myLayout.cells("a").attachLayout("2U");
ViewManutenzioni();
function ViewAttrezzature(){
attrezzatureLayout.cells("a").setText("Lista attrezzature");
attrezzatureLayout.cells("b").setText("Dettaglio");
attrezzatureGrid = attrezzatureLayout.cells("a").attachGrid();
...
attrezzatureGrid.init();
attrezzatureGrid.load("../lib/dhtmlx/data/apparecchiature.php");
attrezzatureGrid.attachEvent("onRowSelect", function(id, ind){
rowSic = attrezzatureGrid.cellById(id,0).getValue(); //non è visto a livello globale
manutenzioniGrid.clearAll();
manutenzioniGrid.load("../lib/dhtmlx/data/manutenzioni-filtered.php?sic="+rowSic);
rowId = attrezzatureGrid.getRowIndex(id); //indice relativo della riga del grid
attrezzatura = attrezzatureGrid.cellByIndex(rowId,1).getValue();;
...
...
function ViewManutenzioni(){
manutenzioniLayout.cells("a").setText("Lista manutenzioni");
manutenzioniLayout.cells("b").setText("Scheda manutenzione");
manutenzioniGrid = manutenzioniLayout.cells("a").attachGrid();
manutenzioniForm.loadStruct("../lib/dhtmlx/data/manutenzioni_form.xml", function(){
var apparecchiatura = ???
manutenzioniForm.getContainer("apparecchiatura_detail").innerHTML = '<h2>'+apparecchiatura+'</h2>';
});
I want to show in the form inside ViewManutenzioni the variable “attrezzatura” defined into ViewAttrezzature.
I need a global variable defined inside a function !! It’s possible??