Hi,
I can not find a solution for this case:
I have a Select2 on my page. The plan was to use it like a filter - show in the report only one item but also I wanted to keep an option to get the report with all items using the empty "" value.
- Select2 code:
Select2::create(array(
"name" => "itemSearchSelect",
"dataStore" => $this->dataStore("items"),
"dataBind" => array(
"text" => "name",
"value" => "id",
),
"options" => array(
"placeholder" => "Select item to search",
"allowClear" => true,
),
));
- Also i set the default value like this:
protected function defaultParamValues()
{
return array(
"itemSearch" =>array(),
);
}
protected function bindParamsToInputs()
{
return array(
"itemSearch" =>"itemSearchSelect",
);
}
- The problem is:
If I open the page the first time - I get the correct report with all items - so the default
array()
works. But in the Select2 I see the first value from the list (actually I expect to see placeholder there). So if I press reload button Select2 works like a filter but I don't need it every time because I have some other inputs and sometimes I need having this Select2 empty. The allowClear option helps just partially - yes I can erase the value using it but I don't want to press it every time before press reload.
Regards, Eugene