Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Data Grid edit inline + Check Box Bom dia pessoal Alguém conseguiu usar o edit inline junto com um form de imput ou check box ? Acreditamos que seja porque quando acionamos o inline ele monta um form em volta do outro form feito para receber os dados do check ou de qualquer imput dessa forma quando clicamos no campo editavel ele simplesmente some. https://www.adianti.com.br/forum/pt/view_4207?datagrid-with-input-fields...
FC
Data Grid edit inline + Check Box  
Bom dia pessoal

Alguém conseguiu usar o edit inline junto com um form de imput ou check box ?

Acreditamos que seja porque quando acionamos o inline ele monta um form em volta do outro form feito para receber os dados do check ou de qualquer imput dessa forma quando clicamos no campo editavel ele simplesmente some.

https://www.adianti.com.br/forum/pt/view_4207?datagrid-with-input-fields-nao-edi

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (2)


FC

  1. <?php
  2. $this->form = new TQuickForm('form_search_OcpRve');
  3. $this->formDatagrid = new TForm('datagrid_form');
  4. $this->datagrid = new TDataGrid;
  5. $this->formDatagrid->add($this->datagrid);
  6. $container = new TVBox;
  7. $container->style 'width: 90%';
  8. $container->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  9. $container->add($this->form);
  10. $container->add($this->formDatagrid);
  11. parent::add($container);
  12. parent::add($this->datagrid); //quando é feitao dessa forma ele funciona o in line , mas não recebe o dados do imput.
  13. ?>

FC

Simulação do problema na classe do tutor.


  1. <?php
  2. /**
  3.  * DatagridQuickView
  4.  *
  5.  * @version    1.0
  6.  * @package    samples
  7.  * @subpackage tutor
  8.  * @author     Pablo Dall'Oglio
  9.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10.  * @license    http://www.adianti.com.br/framework-license
  11.  */
  12. class DatagridCheckView extends TPage
  13. {
  14.     private $form;
  15.     private $datagrid;
  16.     
  17.     public function __construct()
  18.     {
  19.         parent::__construct();
  20.         
  21.         $this->form = new TForm;
  22.         
  23.         // creates one datagrid
  24.         $this->datagrid = new TDataGrid;
  25.         $this->datagrid->disableDefaultClick(); // important!
  26.         
  27.         $this->form->add($this->datagrid);
  28.         
  29.         // add the columns
  30.         $column_check       = new TDataGridColumn('check''Check''center'40);
  31.         $column_code       = new TDataGridColumn('code''code''center'40);
  32.         $column_name       = new TDataGridColumn('name''name''center'40);
  33.         $column_address       = new TDataGridColumn('address''address''center'40);
  34.         $column_fone       = new TDataGridColumn('fone''fone''center'40);
  35.         
  36.         
  37.         $this->datagrid->addColumn($column_check);
  38.         $this->datagrid->addColumn($column_code);
  39.         $this->datagrid->addColumn($column_name);
  40.         $this->datagrid->addColumn($column_address);
  41.         $this->datagrid->addColumn($column_fone);
  42.         
  43.         
  44.         $column_edit = new TDataGridAction(array($this,'onInlineEdit'));
  45.         $column_edit->setField('id');
  46.         $column_name->setEditAction($column_edit);
  47.         
  48.         
  49.         // creates the datagrid model
  50.         $this->datagrid->createModel();
  51.         
  52.         // creates the action button
  53.         $button1=new TButton('action1');
  54.         // define the button action
  55.         $button1->setAction(new TAction(array($this'onSave')), 'Save');
  56.         $button1->setImage('ico_save.png');
  57.         
  58.         $this->form->addField($button1);
  59.         
  60.         // wrap the page content using vertical box
  61.         $vbox = new TVBox;
  62.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  63.         $vbox->add($this->form);
  64.         $vbox->add($button1);
  65.         
  66.         parent::add($vbox);
  67.         
  68.     }
  69.     
  70.     
  71.     public function onInlineEdit($param)
  72.     {
  73.         try
  74.         {
  75.             // get the parameter $key
  76.             $field $param['field'];
  77.             $key   $param['key'];
  78.             $value $param['value'];
  79.             
  80.             $this->onReload($param); // reload the listing
  81.             new TMessage('info'"Record Updated");
  82.         }
  83.         catch (Exception $e// in case of exception
  84.         {
  85.             new TMessage('error''<b>Error</b> ' $e->getMessage()); // shows the exception error message
  86.             TTransaction::rollback(); // undo all pending operations
  87.         }
  88.     }
  89.     
  90.     /**
  91.      * Load the data into the datagrid
  92.      */
  93.     function onReload()
  94.     {
  95.         $this->datagrid->clear();
  96.         
  97.         // add an regular object to the datagrid
  98.         $item = new StdClass;
  99.         $item->check    = new TCheckButton('check1');
  100.         $item->check->setIndexValue('on');
  101.         $item->code     '1';
  102.         $item->name     'Fábio Locatelli';
  103.         $item->address  'Rua Expedicionario';
  104.         $item->fone     '1111-1111';
  105.         $this->datagrid->addItem($item);
  106.         $this->form->addField($item->check); // important!
  107.         
  108.         // add an regular object to the datagrid
  109.         $item = new StdClass;
  110.         $item->check  = new TCheckButton('check2');
  111.         $item->check->setIndexValue('on');
  112.         $item->code     '2';
  113.         $item->name     'Julia Haubert';
  114.         $item->address  'Rua Expedicionarios';
  115.         $item->fone     '2222-2222';
  116.         $this->datagrid->addItem($item);
  117.         $this->form->addField($item->check); // important!
  118.         
  119.         // add an regular object to the datagrid
  120.         $item = new StdClass;
  121.         $item->check  = new TCheckButton('check3');
  122.         $item->check->setIndexValue('on');
  123.         $item->code     '3';
  124.         $item->name     'Carlos Ranzi';
  125.         $item->address  'Rua Oliveira';
  126.         $item->fone     '3333-3333';
  127.         $this->datagrid->addItem($item);
  128.         $this->form->addField($item->check); // important!
  129.         
  130.         // add an regular object to the datagrid
  131.         $item = new StdClass;
  132.         $item->check  = new TCheckButton('check4');
  133.         $item->check->setIndexValue('on');
  134.         $item->code     '4';
  135.         $item->name     'Daline DallOglio';
  136.         $item->address  'Rua Oliveira';
  137.         $item->fone     '4444-4444';
  138.         $this->datagrid->addItem($item);
  139.         $this->form->addField($item->check); // important!
  140.     }
  141.     
  142.     /**
  143.      * Simulates an save button
  144.      * Show the form content
  145.      */
  146.     public function onSave($param)
  147.     {
  148.         $data $this->form->getData(); // optional parameter: active record class
  149.         
  150.         // put the data back to the form
  151.         $this->form->setData($data);
  152.         
  153.         // creates a string with the form element's values
  154.         $message 'Check 1 : ' $data->check1 '<br>';
  155.         $message.= 'Check 2 : ' $data->check2 '<br>';
  156.         $message.= 'Check 3 : ' $data->check3 '<br>';
  157.         $message.= 'Check 4 : ' $data->check4 '<br>';
  158.         
  159.         // show the message
  160.         new TMessage('info'$message);
  161.     }
  162.     
  163.     /**
  164.      * shows the page
  165.      */
  166.     function show()
  167.     {
  168.         $this->onReload();
  169.         parent::show();
  170.     }
  171. }
  172. ?>