Hi,
I have been switching some our grids to popup editing when adding a new grid while keeping to in-line grid editing for existing records. In the following example there are two dropdown lists. The trial site dropdown is filtered based on the country dropdown selection. This currently works fine in the in-line grid editing version: the two drop down editors populate their respective dropdowns initially. When the trial site dropdown is selected it repopulates itself (I assume this is default behavior).
The popup editing behaves differently - there doesn't seem to be any default repopulation on the dropdown on selection.
My work round is to put an change event on the Country drop down editor definition but I am unsure how to refresh the dropdown sites editor from my OnChangeCountry function. Can you help?
regards,
Chris
function
localcountryFilteredSiteLabelDropDownEditor(container, options) {
//Used to filter the site based on country selected in column
var
trail_countries = [];
//trail_countries.push({ trial_site_id: '0', trial_site_label: 'None' });
for
(
var
idx = 0; idx < localCountryFromTrialId.length; idx++) {
if
(localCountryFromTrialId[idx].trial_country_id === options.model.trial_country_id) {
trail_countries.push({ trial_site_id: localCountryFromTrialId[idx][
"trial_site_id"
], trial_site_label: localCountryFromTrialId[idx].trial_site_label });
}
}
$(
'<input name="trial_site_id" data-text-field="trial_site_label" data-value-field="trial_site_id" data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoDropDownList({
name:
"trial_site_id"
,
autoBind:
true
,
dataSource: trail_countries,
optionLabel: { trial_site_label:
" "
, trial_site_id:
null
}
});
CreateValidationMessage(container,
"trial_site_id"
);
}
function
localtrialCountryDropDownEditor(container, options) {
$(
'<input name="trial_country_id" data-text-field="country_name" data-value-field="trial_country_id" data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoDropDownList({
autoBind:
false
,
optionLabel:
"Select country"
,
dataSource: localCountry,
change: onChangeCountry
});
CreateValidationMessage(container,
"countryEditor"
);
}
function
onChangeCountry (container, options) {
// Can i just call the editor function as in the next line of commented out code?
// One problem here is i don't seen to access to "options" reference
localcountryFilteredSiteLabelDropDownEditor(container, options);
// Alternatively can I call a refresh method of my trial site dropdown list but I am unsure how to I get a reference to it
to
do
this
. I think it should be something like
this
in
the following :
//var trial_site_id_object = $("#trial_site_id");
//var dropdownlist = trial_site_id_object.data("kendoDropDownList");
//if (dropdownlist) {
// dropdownlist.refresh();
}