PO
Onde estou errando ? Mostra um Relaciomanto em Grid
Fechado
Estou querendo mostrar um Lista de Suporte com o nome do cliente "RAZAOSOCIAL"
da forma que ta ai não mostra nada no Campo RAZAOSOCIAL VOU MANDA UM IMAGEM EM ANEXO
COMO ESTA VOLTANDO.
da forma que ta ai não mostra nada no Campo RAZAOSOCIAL VOU MANDA UM IMAGEM EM ANEXO
COMO ESTA VOLTANDO.
- <?php
- /**
- * Cliente Active Record
- * @author <your-name-here>
- */
- class Cliente extends TRecord
- {
- const TABLENAME = 'CLIENTE';
- const PRIMARYKEY= 'CODIGO';
- const IDPOLICY = 'max'; // {max, serial}
- /**
- * Constructor method
- */
- public function __construct(1174 = NULL, $callObjectLoad = TRUE)
- {
- parent::__construct(1174, $callObjectLoad);
- parent::addAttribute('RAZAOSOCIAL');
- parent::addAttribute('FANTASIA');
- parent::addAttribute('LOGRADOURO');
- parent::addAttribute('BAIRRO');
- parent::addAttribute('ENDCOMPL');
- parent::addAttribute('CEP');
- parent::addAttribute('FONE');
- parent::addAttribute('FAX');
- parent::addAttribute('CNPJCPF');
- parent::addAttribute('IERG');
- parent::addAttribute('NOMECONTATO');
- parent::addAttribute('CELCONTATO');
- parent::addAttribute('DTCAD');
- parent::addAttribute('EMAIL');
- parent::addAttribute('ORGAOEXP');
- parent::addAttribute('ENDNUM');
- parent::addAttribute('CIDADE');
- parent::addAttribute('RESPONSAVEL');
- parent::addAttribute('DTATULIZACAO');
- parent::addAttribute('LIMITE');
- parent::addAttribute('RESPCOMPRA');
- parent::addAttribute('FONERESPCOMPRA');
- parent::addAttribute('STATUS');
- parent::addAttribute('TIPO');
- parent::addAttribute('CONJUGUE');
- parent::addAttribute('ESTCIVIL');
- parent::addAttribute('DTNASC');
- parent::addAttribute('CLIENTEDESDE');
- parent::addAttribute('TPPGTOAUT');
- parent::addAttribute('PAI');
- parent::addAttribute('MAE');
- parent::addAttribute('SEXO');
- parent::addAttribute('TP_NF');
- }
- }
- <?php
- /**
- * SuporteForm Registration
- * @author <your name here>
- */
- class SuporteForm extends TStandardForm
- {
- protected $form; // form
- /**
- * Class constructor
- * Creates the page and the registration form
- */
- function __construct()
- {
- parent::__construct();
- parent::setDatabase('prov'); // defines the database
- parent::setActiveRecord('Suporte'); // defines the active record
- // creates the form
- $this->form = new TQuickForm('form_Suporte');
- $this->form->class = 'tform'; // CSS class
- $this->form->style = 'width: 500px';
- // define the form title
- $this->form->setFormTitle('Suporte');
- // create the form fields
- $CODIGO = new TEntry('CODIGO');
- $DATACAD = new TDate('DATACAD');
- $CLIENTE = new TEntry('CLIENTE');
- $STATUS = new TEntry('STATUS');
- $FONECONTATO = new TEntry('FONECONTATO');
- $DATARECLAMACAO = new TDate('DATARECLAMACAO');
- $DATAPREVTERNO = new TDate('DATAPREVTERNO');
- $HORARECLAMACAO = new TEntry('HORARECLAMACAO');
- $HORAPREVTERNO = new TEntry('HORAPREVTERNO');
- $PESSOAATENDIDA = new TEntry('PESSOAATENDIDA');
- $TITULOPROBLEMA = new TEntry('TITULOPROBLEMA');
- $DESCRICAOPROBLEMA = new TEntry('DESCRICAOPROBLEMA');
- $FUNCIONARIOATENDEU = new TEntry('FUNCIONARIOATENDEU');
- $DATABAIXA = new TDate('DATABAIXA');
- $HORABAIXA = new TEntry('HORABAIXA');
- $COBRANCA = new TEntry('COBRANCA');
- $VALORCOBRADO = new TEntry('VALORCOBRADO');
- $TPSERVICO = new TEntry('TPSERVICO');
- $AB_TECNICO = new TEntry('AB_TECNICO');
- $FC_TECNICO = new TEntry('FC_TECNICO');
- $TECNICO = new TEntry('TECNICO');
- $DT_DESPACHO = new TDate('DT_DESPACHO');
- $HR_DESPACHO = new TEntry('HR_DESPACHO');
- // add the fields
- $this->form->addQuickField('CODIGO', $CODIGO, 100);
- $this->form->addQuickField('DATACAD', $DATACAD, 100);
- $this->form->addQuickField('CLIENTE', $CLIENTE, 100);
- $this->form->addQuickField('STATUS', $STATUS, 200);
- $this->form->addQuickField('FONECONTATO', $FONECONTATO, 200);
- $this->form->addQuickField('DATARECLAMACAO', $DATARECLAMACAO, 100);
- $this->form->addQuickField('DATAPREVTERNO', $DATAPREVTERNO, 100);
- $this->form->addQuickField('HORARECLAMACAO', $HORARECLAMACAO, 200);
- $this->form->addQuickField('HORAPREVTERNO', $HORAPREVTERNO, 200);
- $this->form->addQuickField('PESSOAATENDIDA', $PESSOAATENDIDA, 200);
- $this->form->addQuickField('TITULOPROBLEMA', $TITULOPROBLEMA, 200);
- $this->form->addQuickField('DESCRICAOPROBLEMA', $DESCRICAOPROBLEMA, 200);
- $this->form->addQuickField('FUNCIONARIOATENDEU', $FUNCIONARIOATENDEU, 100);
- $this->form->addQuickField('DATABAIXA', $DATABAIXA, 100);
- $this->form->addQuickField('HORABAIXA', $HORABAIXA, 200);
- $this->form->addQuickField('COBRANCA', $COBRANCA, 200);
- $this->form->addQuickField('VALORCOBRADO', $VALORCOBRADO, 100);
- $this->form->addQuickField('TPSERVICO', $TPSERVICO, 200);
- $this->form->addQuickField('AB_TECNICO', $AB_TECNICO, 100);
- $this->form->addQuickField('FC_TECNICO', $FC_TECNICO, 100);
- $this->form->addQuickField('TECNICO', $TECNICO, 100);
- $this->form->addQuickField('DT_DESPACHO', $DT_DESPACHO, 100);
- $this->form->addQuickField('HR_DESPACHO', $HR_DESPACHO, 200);
- // create the form actions
- $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
- $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
- // add the form to the page
- parent::add($this->form);
- }
- }
- <?php
- /**
- * SuporteList Listing
- * @author <your name here>
- */
- class SuporteList extends TStandardList
- {
- protected $form; // registration form
- protected $datagrid; // listing
- protected $pageNavigation;
- /**
- * Class constructor
- * Creates the page, the form and the listing
- */
- public function __construct()
- {
- parent::__construct();
- parent::setDatabase('prov'); // defines the database
- parent::setActiveRecord('Suporte'); // defines the active record
- parent::setDefaultOrder('CODIGO', 'asc'); // defines the default order
- parent::addFilterField('CODIGO', 'like'); // add a filter field
- parent::addFilterField('CLIENTE', 'like'); // add a filter field
- parent::addFilterField('PESSOAATENDIDA', 'like'); // add a filter field
- // creates the form, with a table inside
- $this->form = new TQuickForm('form_search_Suporte');
- $this->form->class = 'tform'; // CSS class
- $this->form->setFormTitle('Suporte');
- // create the form fields
- $CODIGO = new TEntry('CODIGO');
- $CLIENTE = new TEntry('CLIENTE');
- $PESSOAATENDIDA = new TEntry('PESSOAATENDIDA');
- // add the fields
- $this->form->addQuickField('CODIGO', $CODIGO, 100);
- $this->form->addQuickField('CLIENTE', $CLIENTE, 100);
- $this->form->addQuickField('PESSOAATENDIDA', $PESSOAATENDIDA, 200);
- // keep the form filled during navigation with session data
- $this->form->setData( TSession::getValue('Suporte_filter_data') );
- // add the search form actions
- $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'ico_find.png');
- // $this->form->addQuickAction(_t('New'), new TAction(array('SuporteForm', 'onEdit')), 'ico_new.png');
- // creates a DataGrid
- $this->datagrid = new TQuickGrid;
- $this->datagrid->setHeight(320);
- // creates the datagrid columns
- $CODIGO = $this->datagrid->addQuickColumn('CODIGO', 'CODIGO', 'right', 100);
- $CLIENTE = $this->datagrid->addQuickColumn('CLIENTE_ID', 'CLIENTE_ID', 'right', 100);
- $RAZAOSOCIAL = $this->datagrid->addQuickColumn('RAZAOSOCIAL', 'cliente_name', 'left', 250); /// O ERRO ESTA AQUI EU ACHO !!!
- $TITULOPROBLEMA = $this->datagrid->addQuickColumn('TITULOPROBLEMA', 'TITULOPROBLEMA', 'left', 200);
- $DATARECLAMACAO = $this->datagrid->addQuickColumn('DATARECLAMACAO', 'DATARECLAMACAO', 'left', 100);
- $HORARECLAMACAO = $this->datagrid->addQuickColumn('HORARECLAMACAO', 'HORARECLAMACAO', 'left', 200);
- $PESSOAATENDIDA = $this->datagrid->addQuickColumn('PESSOAATENDIDA', 'PESSOAATENDIDA', 'left', 200);
- $DESCRICAOPROBLEMA = $this->datagrid->addQuickColumn('DESCRICAOPROBLEMA', 'DESCRICAOPROBLEMA', 'left', 200);
- // create the datagrid actions
- $edit_action = new TDataGridAction(array('SuporteForm', 'onEdit'));
- $delete_action = new TDataGridAction(array($this, 'onDelete'));
- // add the actions to the datagrid
- // $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'CODIGO', 'ico_edit.png');
- // $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'CODIGO', 'ico_delete.png');
- // create the datagrid model
- $this->datagrid->createModel();
- // create the page navigation
- $this->pageNavigation = new TPageNavigation;
- $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
- $this->pageNavigation->setWidth($this->datagrid->getWidth());
- // create the page container
- $container = TVBox::pack( $this->form, $this->datagrid, $this->pageNavigation);
- parent::add($container);
- }
- }
Você está certo.
$RAZAOSOCIAL = $this->datagrid->addQuickColumn('Aqui é o Label', 'RAZAOSOCIAL', 'left', 250); /// O ERRO ESTA AQUI EU ACHO !!!
Isso mesmo no data grid rápido (TStandardList) o primeiro campo é o Label o segundo deve ser o nome do campo da tabela/model
Paulo,
Leia este artigo que eu escrevi, vai elucidar esta questão:
www.adianti.com.br/forum/pt/view_876?pensando-em-objetos-nao-em-sql-
Você precisa fazer um método get_cliente() na classe model Suporte. Este método
deverá retornar o objeto cliente relacionado;
E então usar esse atributo na datagrid:
"cliente->RAZAOSOCIAL"
Outra coisa, procure seguir padrões de nomenclatura em banco de dados.
Não há motivos para usar tudo em maiúsculo. Chaves estrangeiras devem se chamar
cliente_id ou id_cliente, tornando mais fácil a leitura. São padrões globais ;-)
Att,
Pablo
mas como altero por exemplo o nome dos label do TDBSeekButton, por exemplo eu tenho um campo onde vou buscar os nomes até ai eu entendi , mas na hora de clicar sobre a lupa(de buscar) ele aparece uma nova janela modal com a listagem das cidades(ou qualquer outro banco de dados previamente setado) o problema tá no cabeçalho da coluna que aparece :
ID | FIELD | FIELD |
eu queria que aparecece
LOCAL | Nome do Local | Catagoria
como mudo os cabeçalhos???
Fernando,
O TDBseekButton faz um simplão mesmo.
Se você quiser personalizar, tem de partir para seek manual:
www.adianti.com.br/framework_files/tutor/index.php?class=FormSeekBut
www.adianti.com.br/framework_files/tutor/index.php?class=CitySeek
Att,
Estou com o mesmo problema e mesmo consultando o livro, as vídeo-Aulas e este fórum não consegui resolver... segue meu código para ver se pelo algum fera pode me ajudar...
Código da Model...
Código da Control...
No aguardo...</your>
Cleiton,
Evite criar comentários em POSTS antigos já resolvidos.
Dificulta a pesquisa e prejudica os registros.
Prefira abrir POSTS novos.
Seu método get_gestado() está com 2 returns.
Além disso, a sintaxe usada na datagrid está errada.
Você usou:
gestado_id -> estado
Quando o correto é:
estado->nome
Veja o exemplo CustomerDataGridView do tutor que tem um exemplo funcionando:
Retorna o nome da cidade. Primeiro dá um get_city(), e a partir dele, retorna o name:
$this->datagrid->addQuickColumn('City', 'city->name', 'left', 140, new TAction(array($this, 'onReload')), array('order', 'city->name'));
Att,