@inherits DataFilterBaseComponent<ComboBoxControl>

<select style="@GetStyle"
        name="@Control.Name"
        disabled="@IsDisabled"
        @onchange="OnChanged">
    @foreach (var item in Control.Items)
    {
        <option selected="@(item == Control.SelectedItem)"
                value="@item">
            @item
        </option>
    }
</select>

@code {

    private void OnChanged(ChangeEventArgs e)
    {
        Control.SelectedItem = e.Value;
        ComboBoxChange();

        Refresh();
    }

    protected override void OnParametersSet()
    {
        base.OnParametersSet();

        if (Control.Items.Count == 0)
        {
            Control.FillData();
            ControlFilterRefresh();
        }
        else
        {
            if (Control.SelectedIndex == -1)
                Control.SelectedIndex = 0;
            Control.SelectedItem = Control.Items[Control.SelectedIndex];
            Control.Text = Control.SelectedItem.ToString();
        }

        // before or after ?
        Control.FilterData();
    }

    private void ComboBoxChange()
    {
        ControlFilterRefresh();
        Control.OnSelectedIndexChanged(null);
    }
}
