<?php

/**
 *
 */
class gridList2 extends MGrid
{
    /**
     *
     */
    public function __construct()
    {
        // get 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');

        // define a range to limit the number of records retrieved
        // pn_page is a variable passed by grid at URL
        $range = new MRange(MForm::getFormValue('pn_page'),15,100);

        // execute the list of aluno.class
        $query   = $objAluno->listAttributes('idAluno,nome','idAluno',$range);

        // define columns for the grid
        $columns = array( new MGridColumn( 'Id', 'right', true, '7%', true, null, false, true ),
                          new MGridColumn( _M('Nome completo'), 'left', true, '90%', true, null, false, true ),
                         );

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

        $this->setRange($range);

        // get icons from a css file with custom images
        $css = $this->manager->getModulePath( 'example', $this->manager->getConf('home.module.html') . '/css/example_icons.css'  );
        $this->manager->getUI()->loadIcons($css); 

        // set the grid's title
        $this->setTitle( _M('Grid of Alunos [Array grid]') );

        // define 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') );


        // add actions to the grid
        $this->addActionUpdate( $href_edit );
        $this->addActionDelete( $href_dele );
        $this->addActionIcon( 'ID','select.gif',$action );
        $this->addActionText( 'alt','Editar',$href_edit );

        // add action with custom image - path of image is inside CSS file
        $this->addActionIcon( 'ID','properties',$href_edit );

    }
}
?>