/** * @param Renderer $renderer * @return void */ public function Render(Renderer $renderer) { $params = ArrayWrapper::createGetWrapper(); $term = $params->isValueSet('term') ? $params->getValue('term') : ''; if ($params->isValueSet('term')) { $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . $term . '%', 'ILIKE', true)); } if ($params->isValueSet('id')) { $this->dataset->AddFieldFilter($this->idField, FieldFilter::Equals($params->getValue('id'))); } if ($this->itemCount > 0) { $this->dataset->SetUpLimit(0); $this->dataset->SetLimit($this->itemCount); } $this->dataset->Open(); $result = array(); $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->valueField, Argument::$Arg4 => $term)); while ($this->dataset->Next()) { $result[] = array("id" => $this->dataset->GetFieldValueByName($this->idField), "label" => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->valueField), $this->valueField), "value" => $this->dataset->GetFieldValueByName($this->valueField)); } echo SystemUtils::ToJSON($result); $this->dataset->Close(); }