ublabloo Datagrid setCondition (NetteDatabaseDataSource)
- Honza.Mottl
- Člen | 104
Pouzivam ublabloo Datagrid 5.6 s NetteDatabaseDataSource.
Potreboval bych si vytvorit vlastni podminku. Priklad je na DibiFluent a
s NetteDatabaseDataSource mi to vypadne na exception, protoze parametr $fluent
je string.
Nevite nekdo jak to ma vypadat pod NetteDatabaseDataSource? Diky
$grid->addFilterText('custom', 'Custom search:', 'name')
->setCondition(function($fluent, $value) {
/**
* The data source is here DibiFluent
* No matter what data source you are using,
* prepared data source will be passed as the first parameter of your callback function
*
* S NetteDatabaseDataSource to nefunguje, $fluent je string
*/
$fluent->where('id > ?', strlen($value));
});
- Honza.Mottl
- Člen | 104
Uz jsem na to prisel. Musim pridat podminku a dat cely SELECT jako navratovou hodnotu :D
$grid->addFilterSelect('objednavka_type', 'Druh:', $this->druhObjednavky)->setCondition(function($sqlStmt, $value) {
switch ($value) {
case ObjednavkaManager::TYPE_A:
case ObjednavkaManager::TYPE_B:
case ObjednavkaManager::TYPE_C:
$condition = " (objednavka_type IN ('".ObjednavkaManager::TYPE_A."','".ObjednavkaManager::TYPE_B."','".ObjednavkaManager::TYPE_C."')) ";
break;
default:
$condition = " (objednavka_type = '$value') ";
break;
}
$sqlStmt .= ' AND '.$condition;
return $sqlStmt;
});