<?php

/**
 *
 */
class gridList1 extends MGrid
{
    /**
     *
     */
    public function __construct()
    {
        // returns an instance of MIOLO
        $MIOLO = MIOLO::getInstance();
        // get the url of the current page
        $listURL = $MIOLO->getCurrentURL();
        // creates an aluno object
        $objAluno = $MIOLO->getBusiness( 'example', 'aluno');
        // execute the list of aluno.class
        $query   = $objAluno->listAttributes('idAluno,nome,idCurso');
        // creates an curso object
        $objCurso = $MIOLO->getBusiness( 'example', 'curso');
        // execute the listAll of curso.class
        $queryCurso   = $objCurso->listAll();
        // get the curso::nome
        $cursos  = $queryCurso->chunkResult();
        foreach($cursos as $i=>$v) $cursos[$i] = utf8_encode($v);
        // define the grid columns
        $columns = array( new MGridColumn( 'Id', 'right', true, '10%', true, null, false, true ),
                          new MGridColumn( 'Nome', 'left', true, '70%', true, null, false, true),
                          new MGridColumn( 'Curso', 'left', true, '20%', true, $cursos, false, true )
                         );

        // call the parent's constructor
        parent::__construct( $query->result, $columns, $listURL, 15, 0 );

        // set the grid title
        $this->setTitle( 'Alunos [Simple array grid]' );
    }
}

?>