覆盖 ext.net 组合框的最佳方法

Best way to override ext.net combobox

我试图找到一些覆盖 ext.net combobox 的示例。我需要这样做,因为我想为大多数属性使用默认值。但我有一个问题。我找不到 storehandlerproxy 和我自己的 listenerscombobox 中使用的示例。我怎样才能覆盖它?谁能给我一些例子吗?

自己的 combobox 的 C# class 示例。谢谢。

编辑...

public class CombinedComboBox : ComboBox
{
    #region Properties

    private string _handlerAddress;
    private Store _store;
    private StoreParameterCollection _storeParameters;
    private ModelFieldCollection _modelFields;
    private ListenerCollection _listeners;

    public string HandlerAddress
    {
        get { return _handlerAddress; }
        set
        {
            if (!value.StartsWith("/Handlers/"))
                _handlerAddress = "/Handlers/" + value;
            else
                _handlerAddress = value;
        }
    }       

    public StoreParameterCollection StoreParameters
    {
        get { return _storeParameters;  }
        set { _storeParameters = value; }
    }

    public ModelFieldCollection ModelFields
    {
        get { return _modelFields; }
        set { _modelFields = value;  }
    }

    #endregion

    #region ASP.NET Controls Init & Events

    public CombinedComboBox()
    {
        //Базовые автоматические значения, также можно просадить в Init
        HideLabel = false;
        DisplayField = "Name";
        PageSize = 10;
        TypeAhead = true;
        LabelWidth = 160;
        MinChars = 2;
    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        BuildStore();

        if (!AllowBlank) AfterLabelTextTpl.Html = "<span style=\"color: red; font - weight: bold\" data-qtip=\"Required\">*</span>";
    }

    private void BuildStore()
    {
        _store = new Store
        {
            AutoLoad = false,
            RemotePaging = true,
            RemoteFilter = true,
            IsPagingStore = true,
            PageSize = PageSize
        };

        _store.Proxy.Add(new AjaxProxy
        {
            Json = true,
            ActionMethods = { Read = HttpMethod.GET },
            Url = HandlerAddress,
            Reader = { new JsonReader { Root = "data", TotalProperty = "total" } }
        });            

        if (_storeParameters != null && _storeParameters.Count > 0)
        {
            foreach (var item in _storeParameters)
            {
                _store.Parameters.Add(item);
            }
        }

        _store.AutoLoadParams.Add(new Parameter("start", "0"));
        _store.AutoLoadParams.Add(new Parameter("limit", PageSize.ToString()));

        Model model = new Model { IDProperty = "Id" };
        model.Fields.Add(new ModelField("Id", ModelFieldType.String));
        model.Fields.Add(new ModelField("Name", ModelFieldType.String));

        if (_modelFields != null && _modelFields.Count > 0)
        {
            foreach (var item in _modelFields)
            {
                model.Fields.Add(item);
            }                
        }
        _store.Model.Add(model);

        Bin.Add(_store);
    }
    #endregion
}

我的网络表单:

<elem:CombinedComboBox                                                 
                                            ID="MyId"
                                            runat="server"
                                            EmptyText="Text"
                                            FieldLabel="Text"
                                            HandlerAddress="/Handlers/OrgStructureDirectionsListHandler.ashx">                                                
                                            <StoreParameters>
                                                <ext:StoreParameter Name="DirectionType" Value="SomeDirection" Mode="Value" />
                                            </StoreParameters>
                                            <Listeners>
                                                <Select Fn="ItemSelected"/>
                                            </Listeners>
                                            </elem:CombinedComboBox>

但是 Handler 从未调用过。为什么?

好的,我发现了一个问题。这是因为我没有像这样为我的商店放置ID:

        protected override void OnPreRender(EventArgs e)
    {
        StoreID = _store.ClientID;
        base.OnPreRender(e);
    }