Reputation: 1011
When calling ASPxClientComboBox.AddItem()
I get an error in the _aspxRemoveAttribute
function, that obj is null.
I've traced it to the CreateNewItem
function, which never returns a result.
My combo box starts unpopulated, and I'm trying to add items on the client side, but I got the same error when trying to add items to a combo box with items already added from the server side.
This is using the v2011 vol 2.5 release.
EDIT Here is the combo box markup:
<dx:ASPxComboBox ID="txtCountry" runat="server" Width="95%" data-bind="dxDataBind: Countries, keyMember: 'Id', displayMember: 'Name', SelectedKey: CountryId">
<ValidationSettings>
<RequiredField IsRequired="True" ErrorText="Country required" />
</ValidationSettings>
</dx:ASPxComboBox>
The data-bind attribute is part of KnockoutJS, which I am attempting to adapt to bind to other controls.
Essentially at the moment I'm just trying to add an item to an empty combo box on the client side, with two string parameters.
Upvotes: 1
Views: 1986
Reputation: 9300
Specify the ASPxComboBox.ClientInstanceName property to enable the control’s client-side programmatic object and use the client-side AddItem method as follows:
<dx:ASPxComboBox ID="txtCountry" runat="server" Width="95%" ClientInstanceName="cmb">
<ValidationSettings>
<RequiredField IsRequired="True" ErrorText="Country required" />
</ValidationSettings>
</dx:ASPxComboBox>
<input type="button" value="Add Item" onclick="OnClick();" />
<script type="text/javascript">
function OnClick() {
var text="Text1";
var value="Value1";
cmb.AddItem(text, value);
}
</script>
Upvotes: 0
Reputation: 1011
Embarassingly I worked out this was due to EnableClientSideScript not being enabled. However the client side api was available, it just did not function correctly, which doesn't seem like the correct behaviour.
Upvotes: 1