-
Notifications
You must be signed in to change notification settings - Fork 1
/
Index.cshtml
45 lines (45 loc) · 1.32 KB
/
Index.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@{
ViewBag.Title = "GridView - How to implement cascading comboboxes in the EditForm";
}
<script type="text/javascript">
var customCallback = false;
var editingStart = false;
var previousValue = null;
function onBeginCallback(s, e) {
if (e.command = "STARTEDIT")
editingStart = true;
}
function onEndCallback(s, e) {
if (editingStart) {
customCallback = true;
var editor = grid.GetEditor('CityId');
if (editor) {
previousValue = editor.GetValue();
editor.PerformCallback();
}
}
}
function CountriesCombo_SelectedIndexChanged(s, e) {
customCallback = true;
grid.GetEditor('CityId').PerformCallback();
}
function CitiesCombo_BeginCallback(s, e) {
e.customArgs['CountryId'] = grid.GetEditor('CountryId').GetValue();
}
function CitiesCombo_EndCallback(s, e) {
var editor = MVCxClientComboBox.Cast(s);
if (customCallback) {
customCallback = false;
if (previousValue) {
editor.SetValue(previousValue);
previousValue = null;
} else {
editor.SetSelectedIndex(0);
}
}
}
</script>
@using (Html.BeginForm())
{
@Html.Partial("GridViewPartial")
}