I am running into problem, where i am not sure how to do this.
I am attempting to do Cascading Combo box inside the Grid using JQuery(No MVC).
I will need to use it in both inline & POPUP mode.
1) How to i refresh the State & City Combo when i change the selection of Country.
a) I also need to pass some additional data from other Column, along with selected country to webAPI method
2) I want to display CountryName, StateName & CityName in their foreign key, when not i edit mode, how can i do that.
(during submit, i want the ID's to be submitted back to the server & not the Names)
NOTE: CountryID_FK, StateID_FK,CityID_FK are Foreign keys.
{
field: "CountryID_FK",
width: 110,
editor: CountiresComboEditor
},
{
field: "StateID_FK",
width: 110,
editor: StateComboEditor
},
{
field: "CityID_FK",
width: 110,
editor: CitiesComboEditor
}
function CountiresComboEditor(container, options) {
$('<input id="CountryDDL1" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: {
url: baseURL + "/GetCountries", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "CountryID_PK",
change: function () {
// Not sure how to refresh the State & City DDL
var ddlstate = $("#StateDDL").data("kendoDropDownList");
ddlstate .refresh();
var ddlcity = $("#CityDDL").data("kendoDropDownList");
ddlcity .refresh();
}
});
}
function StateComboEditor(container, options) {
$('<input id="StateDDL" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: {
url: baseURL + "/GetStates", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "StateID_PK",
change: function () {
var ddlCity = $("#CityDDL").data("kendoDropDownList");
ddlCity.refresh();
}
});
}
function CitiesComboEditor(container, options) {
$('<input id="CityDDL" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: true,
dataSource: {
transport: {
read: {
url: baseURL + "/GetCities", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "CityID_PK"
});
}
I am attempting to do Cascading Combo box inside the Grid using JQuery(No MVC).
I will need to use it in both inline & POPUP mode.
1) How to i refresh the State & City Combo when i change the selection of Country.
a) I also need to pass some additional data from other Column, along with selected country to webAPI method
2) I want to display CountryName, StateName & CityName in their foreign key, when not i edit mode, how can i do that.
(during submit, i want the ID's to be submitted back to the server & not the Names)
NOTE: CountryID_FK, StateID_FK,CityID_FK are Foreign keys.
{
field: "CountryID_FK",
width: 110,
editor: CountiresComboEditor
},
{
field: "StateID_FK",
width: 110,
editor: StateComboEditor
},
{
field: "CityID_FK",
width: 110,
editor: CitiesComboEditor
}
function CountiresComboEditor(container, options) {
$('<input id="CountryDDL1" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: {
url: baseURL + "/GetCountries", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "CountryID_PK",
change: function () {
// Not sure how to refresh the State & City DDL
var ddlstate = $("#StateDDL").data("kendoDropDownList");
ddlstate .refresh();
var ddlcity = $("#CityDDL").data("kendoDropDownList");
ddlcity .refresh();
}
});
}
function StateComboEditor(container, options) {
$('<input id="StateDDL" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: {
url: baseURL + "/GetStates", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "StateID_PK",
change: function () {
var ddlCity = $("#CityDDL").data("kendoDropDownList");
ddlCity.refresh();
}
});
}
function CitiesComboEditor(container, options) {
$('<input id="CityDDL" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: true,
dataSource: {
transport: {
read: {
url: baseURL + "/GetCities", // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
}
},
schema: {
data: function (data) {
return data.Items; // <-- The result is just the data, it doesn't need to be unpacked.
}
}
},
dataTextField: "Name",
dataValueField: "CityID_PK"
});
}