WG
Adianti Studio: datagrid falha adicionando items na renderização
Fechado
Criei um datagrid no Adianti Studio e ao tentar renderizá-lo, meu método onReload dá erro na hora que tenta adicionar um objeto ao datagrid... podem me ajudar a achar o problema?
Erro: Fatal error: Cannot access empty property in D:DropboxEstudosAdianti TestelibadiantiwidgetwebdatagridTDataGrid.class.php on line 256
datagrid.form.xml
Erro: Fatal error: Cannot access empty property in D:DropboxEstudosAdianti TestelibadiantiwidgetwebdatagridTDataGrid.class.php on line 256
datagrid.form.xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<tdatagrid id="0">
<class>TDataGrid</class>
<name>datagrid</name>
<x>10</x>
<y>10</y>
<loader>onReload</loader>
<template></template>
<width>400</width>
<height>300</height>
<columns>
<tdatagridcolumn id="1">
<name>id</name>
<align>left</align>
<label>ID</label>
<width>40</width>
</tdatagridcolumn>
<tdatagridcolumn id="2">
<name>name</name>
<align>left</align>
<label>Nome</label>
<width>360</width>
</tdatagridcolumn>
</columns>
<actions>
<tdatagridaction id="1">
<method>onEdit</method>
<image>ico_edit.png</image>
<field></field>
<label>Editar</label>
<template></template>
</tdatagridaction>
</actions>
<pagenavigator>yes</pagenavigator>
</tdatagrid>
</form>
DesignDataGridView.class.php
php
<form>
<tdatagrid id="0">
<class>TDataGrid</class>
<name>datagrid</name>
<x>10</x>
<y>10</y>
<loader>onReload</loader>
<template></template>
<width>400</width>
<height>300</height>
<columns>
<tdatagridcolumn id="1">
<name>id</name>
<align>left</align>
<label>ID</label>
<width>40</width>
</tdatagridcolumn>
<tdatagridcolumn id="2">
<name>name</name>
<align>left</align>
<label>Nome</label>
<width>360</width>
</tdatagridcolumn>
</columns>
<actions>
<tdatagridaction id="1">
<method>onEdit</method>
<image>ico_edit.png</image>
<field></field>
<label>Editar</label>
<template></template>
</tdatagridaction>
</actions>
<pagenavigator>yes</pagenavigator>
</tdatagrid>
</form>
DesignDataGridView.class.php
- <?php
- class DesignDataGridView extends TPage
- {
- private $form;
- private $datagrid;
- private $loaded;
- function __construct()
- {
- parent::__construct();
- // cria o formulário
- $this->form = new TForm('form_Teste');
- try
- {
- // cria o painel TUIBuilder
- $ui = new TUIBuilder(500, 400);
- $ui->setController($this);
- $ui->setForm($this->form);
- // interpreta o XML
- $ui->parseFile('app/forms/datagrid.form.xml');
- // obtém o objeto datagrid
- $this->datagrid = $ui->getWidget('datagrid');
- $this->form->add($ui);
- $this->form->setFields($ui->getFields());
- }
- catch(Exception $e)
- {
- new TMessage('error', $e->getMessage());
- }
- parent::add($this->form);
- }
- function onEdit($param)
- {
- new TMessage('info', "Editing Record {$param['key']}");
- }
- function onReload($param=NULL)
- {
- $this->datagrid->clear();
- $object = new StdClass;
- $object->id = 1;
- $object->name = 'Wemerson Guimarães';
- $this->datagrid->addItem($object);
- $this->loaded = true;
- }
- function show()
- {
- if(!$this->loaded)
- {
- $this->onReload();
- }
- parent::show();
- }
- }
- ?>
Curso Dominando o Adianti Framework
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!
Dominando o Adianti Framework Quero me inscrever agora!
Esqueci de mencionar que o erro acontece na linha, 50 da classe, justamente ao tentar adicionar o item..
Wemerson,
Na action da datagrid faltou preencher o "field", que trata-se da identificação do campo que será passado como parâmetro, normalmente o ID do registro.
Atenciosamente,
Pablo
Bom dia Pablo...
Obrigado pela resposta... realmente bastou isso!
Foquei no código e como o formulário aparentemente estava desenhado, não me ocorreu que poderia ser algo do datagrid!
Valeu!!
Pablo, estou com outra falha, mas agora é no código do capítulo 7 (páginas 30 a 335)... como ainda é relacionado a datagrid e ao livro, postei nessa mesma dúvida pra não ficar criando posts parecidos...
Ao "Salvar", recebo a mensagem "Records saved", indicando que os dados foram armazenados na seção através da chave persisted_objects, porém logo em seguida aparece a mensagem abaixo:
Fatal error: Call to undefined method stdClass::show() in D:DropboxEstudosAdianti TestelibadiantiwidgetwebgeneralTElement.class.php on line 188
Abaixo meu código:
formdatagrid.form.xml
<form>
<tframe id="0">
<class>TFrame</class>
<name>frame2</name>
<title>Register:</title>
<x>35</x>
<y>25</y>
<width>375</width>
<height>129</height>
<child>
<tpanel>
<tlabel id="0">
<class>TLabel</class>
<name>label2</name>
<x>10</x>
<y>10</y>
<color>#000000</color>
<size>10</size>
<style></style>
<value>Identification:</value>
</tlabel>
<tentry id="1">
<class>TEntry</class>
<name>id</name>
<x>95</x>
<y>10</y>
<value></value>
<mask></mask>
<width>97</width>
<maxlen>0</maxlen>
<editable>1</editable>
<tip></tip>
<required></required>
</tentry>
<tlabel id="2">
<class>TLabel</class>
<name>label3</name>
<x>10</x>
<y>40</y>
<color>#000000</color>
<size>10</size>
<style></style>
<value>Name:</value>
</tlabel>
<tentry id="3">
<class>TEntry</class>
<name>name</name>
<x>95</x>
<y>40</y>
<value></value>
<mask></mask>
<width>252</width>
<maxlen>0</maxlen>
<editable>1</editable>
<tip></tip>
<required></required>
</tentry>
<tbutton id="4">
<class>TButton</class>
<name>Save</name>
<x>280</x>
<y>75</y>
<value>Salvar</value>
<icon>ico_save.png</icon>
<action>onSave</action>
<template></template>
</tbutton>
</tpanel>
</child>
</tframe>
<tframe id="1">
<class>TFrame</class>
<name>frame3</name>
<title>Listing:</title>
<x>35</x>
<y>170</y>
<width>375</width>
<height>245</height>
<child>
<tpanel>
<tdatagrid id="0">
<class>TDataGrid</class>
<name>datagrid1</name>
<x>10</x>
<y>10</y>
<loader>onReload</loader>
<template></template>
<width>345</width>
<height>200</height>
<columns>
<tdatagridcolumn id="1">
<name>id</name>
<align>left</align>
<label>Identification</label>
<width>85</width>
</tdatagridcolumn>
<tdatagridcolumn id="2">
<name>name</name>
<align>left</align>
<label>Name</label>
<width>250</width>
</tdatagridcolumn>
</columns>
<actions>
<tdatagridaction id="1">
<method>onEdit</method>
<image>ico_edit.png</image>
<field>id</field>
<label>Edit</label>
<template></template>
</tdatagridaction>
<tdatagridaction id="2">
<method>onDelete</method>
<image>ico_delete.png</image>
<field>id</field>
<label>Delete</label>
<template></template>
</tdatagridaction>
</actions>
<pagenavigator>no</pagenavigator>
</tdatagrid>
</tpanel>
</child>
</tframe>
</form>
DesignFormDataGridView
Só um erro de digitação. É addItem():
Att,
Pablo
Fala sério!
Não entendo como é que a gente lê e confere várias vezes e não acha o erro... ainda mais sendo um erro tão besta!
boa noite, eu ainda não comprei o livro, comecei a desenvolver esta semana e tive o mesmo erro do colega acima, porém eu não digitei linha alguma eu fiz a classe e a pagina usando o studio pro e uma tabela no banco de dados
e este tal de addItem veio sozinho, mas ainda estou testando, e eu estava com outro erro, a minha coluna no banco id estava maiúscula e estava dando erro de key contornei no código para minúscula e ficou sem novidades.
a questão agora é como traduzir a mensagens tais como (Do you really want to delete)
Rodrigo,
www.adianti.com.br/forum/pt/view_441?erro-message-not-found