AA
BUSCA NO DATAGRID
Quando tenho uma coluna com um texto muito grande, se o trecho que quero estiver no final, a busca não é feita. Vou postar o código do próprio tutor para ver se me faço entender. Eu acrescentei sobrenomes à Aretha Franklin. Na busca se digitar os dois últimos sobrenomes, não mostra nada.
- <?php
- /**
- * DatagridSearchView
- *
- * @version 1.0
- * @package samples
- * @subpackage tutor
- * @author Pablo Dall'Oglio
- * @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
- * @license http://www.adianti.com.br/framework-license
- */
- class DatagridSearchView extends TPage
- {
- private $datagrid;
- public function __construct()
- {
- parent::__construct();
- // creates one datagrid
- $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
- $this->datagrid->width = '100%';
- // add the columns
- $this->datagrid->addColumn( new TDataGridColumn('code', 'Code', 'center', '10%') );
- $this->datagrid->addColumn( new TDataGridColumn('name', 'Name', 'left', '30%') );
- $this->datagrid->addColumn( new TDataGridColumn('city', 'City', 'left', '30%') );
- $this->datagrid->addColumn( new TDataGridColumn('state', 'State', 'left', '30%') );
- $action1 = new TDataGridAction([$this, 'onView'], ['code'=>'{code}', 'name' => '{name}'] );
- $this->datagrid->addAction($action1, 'View', 'fa:search blue');
- // creates the datagrid model
- $this->datagrid->createModel();
- // search box
- $input_search = new TEntry('input_search');
- $input_search->placeholder = _t('Search');
- $input_search->setSize('100%');
- // enable fuse search by column name
- $this->datagrid->enableSearch($input_search, 'code, name, city, state');
- $panel = new TPanelGroup( _t('Datagrid search') );
- $panel->addHeaderWidget($input_search);
- $panel->add($this->datagrid)->style = 'overflow-x:auto';
- $panel->addFooter('footer');
- // wrap the page content using vertical box
- $vbox = new TVBox;
- $vbox->style = 'width: 100%';
- $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $vbox->add($panel);
- parent::add($vbox);
- }
- /**
- * Load the data into the datagrid
- */
- function onReload()
- {
- $this->datagrid->clear();
- // add an regular object to the datagrid
- $item = new StdClass;
- $item->code = '1';
- $item->name = 'Aretha Franklin Gonçalves Affonso da Armênia';
- $item->city = 'Memphis';
- $item->state = 'Tennessee (US)';
- $this->datagrid->addItem($item);
- // add an regular object to the datagrid
- $item = new StdClass;
- $item->code = '2';
- $item->name = 'Eric Clapton';
- $item->city = 'Ripley';
- $item->state = 'Surrey (UK)';
- $this->datagrid->addItem($item);
- // add an regular object to the datagrid
- $item = new StdClass;
- $item->code = '3';
- $item->name = 'B.B. King';
- $item->city = 'Itta Bena';
- $item->state = 'Mississippi (US)';
- $this->datagrid->addItem($item);
- // add an regular object to the datagrid
- $item = new StdClass;
- $item->code = '4';
- $item->name = 'Janis Joplin';
- $item->city = 'Port Arthur';
- $item->state = 'Texas (US)';
- $this->datagrid->addItem($item);
- }
- /**
- * Executed when the user clicks at the view button
- */
- public static function onView($param)
- {
- // get the parameter and shows the message
- $code = $param['code'];
- $name = $param['name'];
- new TMessage('info', "The code is: <b>$code</b> <br> The name is : <b>$name</b>");
- }
- /**
- * shows the page
- */
- function show()
- {
- $this->onReload();
- parent::show();
- }
- }
- ?>