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

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!


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