<?php

class gridList4 extends MSQLGrid
{
    public $alunos;

    public function __construct()
    {
        global $state;


        // get an MIOLO instance
        $MIOLO = MIOLO::getInstance();

        // inside grid column link
        $href_aluno = $MIOLO->getActionURL( 'example', 'main:aluno', '#0#', array( 'event' => 'btnEdit:click' ) );

        // define the grid's columns
        $columns = array( new MDataGridColumn( 'idaluno', 'Id','right', true, '5%',false),
                          new MDataGridHyperlink( 'nome', 'Aluno (Order)', $href_aluno, '35%', true, null, true ),
                          new MDataGridColumn( 'curso', 'Curso', 'left', true, '30%', true, null, false, true ),
                         );


        // define a action
        $href_grid = $MIOLO->getActionURL( 'example', 'controls:grid4' );

        // set the data
        $database = 'example';
        $sql = new MSQL('a.idaluno, a.nome, c.nome as curso','aluno a, curso c','(a.idcurso=c.idcurso)','a.nome');


        // call the parent's constructor
        parent::__construct( $database, $sql, $columns, $href_grid, 15, 0, 'fullGrid', true );

        // grid width
        $this->setWidth('650px');

        // box title
        $this->setTitle( 'Grid of Alunos [A SQL based grid]' );


        // create grid actions
        $href_edit = $MIOLO->getActionURL( 'example', 'main:aluno', '%0%', array( 'event' => 'btnEdit:click' ) );
        $href_dele = $MIOLO->getActionURL( 'example', 'main:aluno', '%0%', array( 'event' => 'btnDelete:click' ) );
	
        $this->addActionUpdate( $href_edit );
        $this->addActionDelete( $href_dele );
        $this->addActionText( 'alt', _M('Edit'), $href_edit );
        $this->addActionSelect();
        $this->setActionDefault( $href_edit );

        // alternate row background colors?
        $this->setAlternate( true );

    }
}
?>