private function ApplyFilter() { $fieldNames = array(); $fieldFilters = array(); foreach ($this->dataset->GetFields() as $field) { if ($this->page->GetSimpleSearchAvailable() && $this->page->GetGrid()->SearchControl instanceof SimpleSearch) { if ($this->page->GetGrid()->SearchControl->ContainsField($field->GetName())) { if ($field->GetEngFieldType() != ftBlob) { $fieldNames[] = $field->GetName(); $fieldFilters[] = new FieldFilter('%' . $this->value . '%', 'ILIKE', true); } } else { if ($this->dataset->IsLookupFieldByPrimaryName($field->GetName()) != null) { $lookupFieldName = $this->dataset->IsLookupFieldByPrimaryName($field->GetName()); if ($this->page->GetGrid()->SearchControl->ContainsField($lookupFieldName)) { $fieldNames[] = $lookupFieldName; $fieldFilters[] = new FieldFilter('%' . $this->value . '%', 'ILIKE', true); } } } } } if (count($fieldFilters) > 0) { $this->dataset->AddCompositeFieldFilter('OR', $fieldNames, $fieldFilters); } }
public static function FormatDatasetFieldsTemplate(Dataset $dataset, $template, IDelegate $processValue = null) { $result = $template; foreach ($dataset->GetFields() as $field) { if ($dataset->IsLookupField($field->GetNameInDataset())) { $result = StringUtils::ReplaceVariableInTemplate($result, $field->GetAlias(), $processValue == null ? $dataset->GetFieldValueByName($field->GetAlias()) : $processValue->Call($dataset->GetFieldValueByName($field->GetAlias()), $field->GetAlias())); } else { $result = StringUtils::ReplaceVariableInTemplate($result, $field->GetName(), $processValue == null ? $dataset->GetFieldValueByName($field->GetNameInDataset()) : $processValue->Call($dataset->GetFieldValueByName($field->GetNameInDataset()), $field->GetNameInDataset())); } } return $result; }