Reputation: 2475
I have two dev express dropdown controls, one containing "Product Type" and one Containing "Delivery Method". There is one element of each that are directly related to each other in that if one is selected, the other should be selected as well.
The controls are currently declared as such:
<dx:ASPxComboBox runat="server" ID="cbDeliveryMethod" ValueField="Id"
TextField="Name" ClientIDMode="Static" ClientInstanceName="cbDeliveryMethod">
<ClientSideEvents SelectedIndexChanged="cbDeliveryMethodSelection" />
</dx:ASPxComboBox>
<dx:ASPxComboBox runat="server" ID="cbProductType" ValueField="Id"
ValueType="System.String" TextField="Name" ClientIDMode="Static"
ClientInstanceName="cbProductType">
<ClientSideEvents SelectedIndexChanged="cbProductTypeSelection" />
</dx:ASPxComboBox>
The controls render as:
<input class="..." id="cbProductType_I" name="ct100$MainContent$uc...$...cbProductType">
....
<input class="..." id="cbDeliveryMethod_I" name="ct100$MainContent$uc...$...$cbDeliveryMethod" >
and my javascript is currently defined as:
function cbProductTypeSelection(s, e) {
console.log("product type");
var alertMe = $('#cbDeliveryMethod_I').val();
console.log(alertMe); // :(
// $('#cbDeliveryMethod').val('required delivery method here');
debugger;
}
function cbDeliveryMethodSelection(s, e) {
console.log("delviery method");
var alertMe = $('#cbProductType').val();
console.log(alertMe); // :(
// $('#cbProductType').val('required product type here');
debugger;
}
I'm trying to do this all in javascript to avoid the page post-back. The loggers currently come back with empty strings, so I'm led to believe that I'm not properly retrieving the controls. I've been trying to use this resource as a reference: Dev Express & JQuery
Upvotes: 1
Views: 1161
Reputation: 9300
Use the client-side GetValue/SetValue or GetText/SetText methods: ...
function cbProductTypeSelection(s, e) {
var ownValue = s.GetValue();
var ownText = s.GetText();
//ClientInstanceName="cbDeliveryMethod"
var cbDeliveryMethodValue = cbDeliveryMethod.GetValue();
var cbDeliveryMethodText = cbDeliveryMethod.GetText();
}
function cbDeliveryMethodSelection(s, e) {
var ownValue = s.GetValue();
var ownText = s.GetText();
//ClientInstanceName="cbProductType"
var cbProductTypeValue = cbProductType.GetValue();
var cbProductTypeText = cbProductType.GetText();
}
Upvotes: 2