Devexpress组合:无法在客户端将Selected Index设置为高于99

时间:2014-07-21 08:51:17

标签: asp.net webforms devexpress

我使用performCallback在服务器端向我的ASPxCombo添加一个新项目,并希望将我的索引更改为客户端的新项目。我使用DevExpress onEndCallback来执行此操作,如果我的索引是< = 99,它的工作正常。在此之上,索引不会更改。

如果DevExpress的SetSelectedIndex()方法使用索引大于此值,那么有没有人对我来说有点奇怪。

                <dx:ASPxComboBox runat="server" 
                                ID="CmbManufacturer" 
                                ClientInstanceName="cmbManufacturer"
                                CssClass="dxeButtonEdit_LWDisplayEdit_CustomDropDown" 

                                DropDownStyle="DropDownList" 
                                EnableCallbackMode="True"
                                OnCallback="CmbManufacturer_Callback" 
                                ValueType="System.String"
                                FieldName="ID" 
                                TextFormatString="{0}" 
                                FilterBy="Name" 
                                TextField="Name" 
                                ValueField="ID"
                                EnableSynchronization="False" 
                                AllowEdit="false" 
                                ValidationSettings-Display="None"
                                AutoPostBack="False" 
                                Visible="False"
                                Width="400" >
                    <ClientSideEvents SelectedIndexChanged="function(s,e) {OnManufacturerChanged(s,e); }"
                        Init="function(s,e) {LwValidating2(s,e);}" 
                        EndCallback="function(s,e) { OnEndCallbackCmbManufacturer(s,e); }"/>
                </dx:ASPxComboBox>   


        function OnEndCallbackCmbManufacturer(s, e) {
        var index = s.cpSelectedIndex;
        s.SetSelectedIndex(index);
        OnManufacturerChanged(s, e);
    }

1 个答案:

答案 0 :(得分:0)

我已经通过在CallbackpageSize下面的列表前面的dropdownItemList中移动我的新项目来解决了这个问题。然后我可以将组合上的索引更改为Items新索引。

        protected void CmbManufacturer_Callback(object source, CallbackEventArgsBase e)
    {
        var manufacturerName = e.Parameter.Trim();

        // need to move item to top of list because it must be lower than CallbackPagesize to work
        int indexforNewItem = 1;
            try
            {

                int newManufacturerId = SoftwareManufacturer.Update(-1, manufacturerName, "");
                LoadDropDownBoxManufacturer(null);
                int newManufacturerIndex = CmbManufacturer.Items.IndexOfText(manufacturerName);
                CmbManufacturer.Items.Move(newManufacturerIndex, indexforNewItem);
                CmbManufacturer.JSProperties["cpSelectedIndex"] = indexforNewItem;
            }

            catch ()
            {
            }
    }