This question is locked. New answers and comments are not allowed.
I have a grid with two dependent columns, one I have a ClientTemplate where the user can search for a customer.
When selected a customer I need to load the other column with only Items of that Customer.
columns.Bound(c => c.CustomerCode)
.ClientTemplate(string.Format("<#= CustomerCode!= null ? CustomerCode.Code - CustomerCode.Name:''#>"))
.Width(210);
columns.ForeignKey((f => f.CustomerItemId), (IEnumerable)this.ViewData["CustomerItemId"], "Id", "Name").Width(175);
This javascript is used to set the value of the fields after selecting the CustomerCode.
function onChangeLookUpFieldCustomerCode(e) {
var urlAction = '<%= this.Url.Action("GetCustomer", "../AjaxCombo") %>';
$.ajax({
url: urlAction,
type: 'POST',
data: { customerCode: e.value },
complete: null,
success: function(data) {
if (data.Nome != "") {
$('#CustomerCode_Name').val(data.Name);
}
else {
alert('Customer not found');
$('#CustomerCode_Name').val('');
}
}
});
}
In the AjaxComboController where I get the Customer data I'm setting:
this.ViewData["CustomerItemId"] = itemList;
How can I populate the data for the CustomerItem Column?
When selected a customer I need to load the other column with only Items of that Customer.
columns.Bound(c => c.CustomerCode)
.ClientTemplate(string.Format("<#= CustomerCode!= null ? CustomerCode.Code - CustomerCode.Name:''#>"))
.Width(210);
columns.ForeignKey((f => f.CustomerItemId), (IEnumerable)this.ViewData["CustomerItemId"], "Id", "Name").Width(175);
This javascript is used to set the value of the fields after selecting the CustomerCode.
function onChangeLookUpFieldCustomerCode(e) {
var urlAction = '<%= this.Url.Action("GetCustomer", "../AjaxCombo") %>';
$.ajax({
url: urlAction,
type: 'POST',
data: { customerCode: e.value },
complete: null,
success: function(data) {
if (data.Nome != "") {
$('#CustomerCode_Name').val(data.Name);
}
else {
alert('Customer not found');
$('#CustomerCode_Name').val('');
}
}
});
}
In the AjaxComboController where I get the Customer data I'm setting:
this.ViewData["CustomerItemId"] = itemList;
How can I populate the data for the CustomerItem Column?