Menu

Grid-Grid Master-Detail

duncs
2014-04-16
2014-09-22
  • duncs

    duncs - 2014-04-16

    Hi,

    I have a use-case that requires master-detail to be presented as 2 grids. Is it possible to enable Input Parameters on a grid so that I can pass the ID from the master grid to the Input Parameter on the Detail grid?

    thanks

     
  • mcarniel

    mcarniel - 2014-04-16

    Yes you can.
    This is a list of steps to follow:

    • create a window for the master grid

    • set a where clause for the detail grid; the where clause should be something like: "FIELD = :VAR_ID"
      in this way, an input parameter will be automatically set to the detail grid, having the same name (VAR_ID)

    • open the detail of the window previously defined, containing the master grid: go to the
      third folder, "Panels", and press edit button: right click with the mouse button on the root tree node and add a panel of type grid; add the detail grid to that window, for instance put it on the bottom and specify an height

    • uncheck the autoload data for the detail grid, in order to load it only when selecting a row on the master grid

    • create an action of type javascript and then link it to the event "row/node selected" in the events folder of the master grid detail. That js action should contain something like:

    if (gridYYY.getSeletionModel().getSelected()==null)
    return;
    gridXXX.store.baseParams.varId = gridYYY.getSelectionModel().getSelected().get("attrZZZ");
    gridXXX.store.reload();

    where gridXXX is the name of the detail grid: you can find it when opening its detail panel.
    where gridYYY is the name of the master grid: you can find it when opening its detail panel.
    where attrZZZ is the name in "camel" mode of the field in the master grid containing the value to use to filter the second grid.

     
  • cstefano

    cstefano - 2014-09-16

    Salve stò cercando, vorrei creare una griglia di dettaglio legata ad un'altra griglia e stò cercando di seguire l'esempio qui sopra ma al momento di caricare la pagina mi dice "TypeError: grid441.getSeletionModel is not a function", sapete indicarmi perchè?
    il nome in camel mode, di cosa si tratta, io ho trovato all'interno della griglia dettagli il nome campo db (tab_accessori.id_risorsa) ma altro non ho trovato?!?
    Grazie

     
    • Lorenzo Luccon

      Lorenzo Luccon - 2014-09-17

      Salve,
      il problema sembra relativo alla mancanza di un carattere
      grid441.getSeletionModel --> grid441.getSelectionModel().

      Il nome in "camel mode" non è altro che la traduzione di un campo fisico del db in attributo, esempio: TAB_ACCESSORI.ID_RISORSA --> tabAccessori.idRisorsa

      Spero di esserle stato utile, per qualsiasi altro problema non esiti a scriverci.

       
  • cstefano

    cstefano - 2014-09-17

    In effetti le parentesi c'erano, non per altro perchè ho fatto un copia incolla di quello che era scritto nel post:

    if (grid441.getSeletionModel().getSelected()==null)
    return;
    grid651.store.baseParams.varId = grid441.getSelectionModel().getSelected().get("tabAccessori.idRisorsa");
    grid651.store.reload();

    dove grid441 è la Grid master e grid651 la grid detail.

    Ora l'errore è TypeError: L'oggetto non supporta la proprietà o il metodo 'getSelectionModel'

    Grazie

     
    • cstefano

      cstefano - 2014-09-17

      Il tutto messo nell'evento della grid master "click riga o nodo"

       
      • Lorenzo Luccon

        Lorenzo Luccon - 2014-09-17

        Le azioni disponibili mettono già a disposizione alcuni elementi che potrebbero tornarti utili e ti possono mettere al riparo da alcuni possibili errori di sintassi.
        In questo caso l'evento "click riga o nodo" ti mette già a disposizione il record selezionato nella griglia master (grid441). Sfruttando questo la tua azione potrebbe essere la seguente:

        if(vo == null)
        return;
        grid651.store.baseParams.varId = vo['tabAccessori.idRisorsa'];
        grid651.store.reload();

        Se ancora non basta prova a verificare che 'grid651' e 'grid651.store' siano valorizzati correttamente e che nel 'vo' sia presente il valore relativo all'attributo 'tabAccessori.idRisorsa'.

        Spero di esserti stato utile.

         

        Last edit: Lorenzo Luccon 2014-09-17
  • cstefano

    cstefano - 2014-09-17

    La procedura sembra funzionare, ma probabilmente non viene attribuito il valore giusto alla variabile. Come faccio a visualizzare il valore contenuto in grid651, grid651.store e vo. Esiste un avvio dell'applicazione in debug?

     
    • Lorenzo Luccon

      Lorenzo Luccon - 2014-09-17

      Bene che il primo errore sia risolto.

      Per seguire in debug la parte interpretata dipende dal browser che utilizzi:
      - se usi Chrome puoi usare gli "Strumenti per sviluppatori" che trovi nel menù del browser sotto la voce "Strumenti";
      - se usi Mozilla puoi usare FireBug;
      - con IE hai "Developer Tools", ma dipende dalla versione di IE.

       
  • cstefano

    cstefano - 2014-09-20

    RISOLTO
    Buongiorno, volevo condividere la risoluzione del problema.

    if(vo == null)
    return;
    grid651.store.baseParams.varId = vo.idRisorsa; (NO vo['tabAccessori.idRisorsa'])
    grid651.store.reload();

    Saluti

     
    • Lorenzo Luccon

      Lorenzo Luccon - 2014-09-22

      Bene, l'attributo con il nome della tabella davanti serve solo nel caso il campo appartenga ad una tabella secondaria.

       

Log in to post a comment.