<ej:ComboBox ID="cbxSaleSourceCode" runat="server" Width="300px" DataTextField="countryName" DataValueField="index" Placeholder="Select a state">
</ej:ComboBox>
<br />
<ej:ComboBox ID="cbxSaleBatch" runat="server" Width="300px" DataTextField="countryName" DataValueField="index" AllowFiltering="true"></ej:ComboBox>
<ej:Button runat="server" Type="Button" Text="Set DataSource" ClientSideOnClick="showLoading"></ej:Button>
<ej:Button runat="server" Type="Button" Text="Empty DataSource" ClientSideOnClick="nullData"></ej:Button>
<script>
function showLoading(args)
{
$.ajax({
type: "POST",
url: "BatchWS.asmx/GetList",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ sourceCode: $('#<%= cbxSaleSourceCode.ClientID %>').ejComboBox("model.value") }),
success: ej.proxy(function (data) {
$('#<%= cbxSaleBatch.ClientID %>').ejComboBox({
dataSource: data.d,
allowFiltering:true
});
}, this),
eror: function (xmlhttprequest, textstatus, errorthrown) {
HideLoading();
swal("Can not get Batch!");
console.log("error: " + errorthrown);
}
});
}
function nullData(args) {
var comboins = $('#<%= cbxSaleBatch.ClientID %>').data("ejComboBox");
comboins.setModel({ dataSource: null });
}
</script> |
function onChange(args)
{
$.ajax({
type: "POST",
url: "BatchWS.asmx/GetList",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ sourceCode: $('#<%= cbxSaleSourceCode.ClientID %>').ejComboBox("model.value") }),
success: ej.proxy(function (data) {
if (data.d.length > 0) {
$('#<%= cbxSaleBatch.ClientID %>').ejComboBox({
dataSource: data.d,
allowFiltering: true
});
} else {
var comboins = $('#<%= cbxSaleBatch.ClientID %>').data("ejComboBox");
comboins.setModel({ dataSource: null });
}
}, this),
eror: function (xmlhttprequest, textstatus, errorthrown) {
HideLoading();
swal("Can not get Batch!");
console.log("error: " + errorthrown);
}
});
} |