powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Прошу помощи
1 сообщений из 1, страница 1 из 1
Прошу помощи
    #38747134
Alonmaster
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Прошу помощи в ASP.NET MVC Kendo UI

Имеется таблица, в которой для каждого города выбирается своя улица. При создании записи... когда выбрал город, и перехожу к выбору улицы, значение исчезает
Представление Index.cshtml
Код: c#
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.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
@(Html.Kendo().Grid<HouseViewModel>()
      .Name("grid")

      .Columns(columns =>
      {
          //columns.Bound(p => p.City).ClientTemplate("#=City.CityName#").Title("Город").Width(160);
          columns.Bound(p => p.HouseID).Visible(false);

          columns.ForeignKey(p => p.CityID, (System.Collections.IEnumerable) ViewData["Cities"], "CityID", "CityName");
          columns.ForeignKey(p => p.StreetID, (System.Collections.IEnumerable) ViewData["Streets"], "StreetID", "StreetName")
          .EditorTemplateName("ClientStreet");

          
          columns.Bound(p => p.HouseNumber);
          columns.Bound(p => p.HouseChar);

          columns.Bound(p => p.HouseFull);

          columns.Command(command => command.Destroy()).Width(120);
      })
      .ToolBar(toolBar =>
      {
          toolBar.Create();
          toolBar.Save();
      })
      .Editable(editable => editable.Mode(GridEditMode.InCell))
      .Pageable()
      .Sortable()

      .Resizable(resize => resize.Columns(true))
      .Scrollable()
      .HtmlAttributes(new { style = "height:430px;" })
      .DataSource(dataSource => dataSource
          .Ajax()
          .Batch(true)
          .ServerOperation(false)
          .Events(events => events.Error("error_handler"))
          .Model(model =>
          {
              model.Id(p => p.HouseID);
              model.Field(p => p.HouseID).Editable(false);
              model.Field(p => p.HouseFull).Editable(false);
 
          })
          .PageSize(20)
          .Read(read => read.Action("Read", "House"))
              .Create(create => create.Action("Create", "House"))
              .Update(update => update.Action("Update", "House"))
              .Destroy(destroy => destroy.Action("Destroy", "House"))
      ))

<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function() {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
</script>

<script>
    function Cities() {
        return {
            customerId: $("#ClientCity").data("kendoDropDownList").value()
        };
    }
</script>
<script>
    function Streets() {
        return {
            customerId: $("#ClientStreet").data("kendoDropDownList").value()
        };
    }
</script>



Template Editor для выпадающего списка улиц, связанных непосредственно с городами:
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
@model object
<script>
    function getParentId() {
        var row = $(event.srcElement).closest("tr");
        var grid = $(event.srcElement).closest("[data-role=grid]").data("kendoGrid");
        var dataItem = grid.dataItem(row);
        return { CityID: dataItem.CityID };
    }
</script>
@(Html.Kendo().DropDownListFor(m => m)
.Name("StreetID")
.OptionLabel("Выберите Улицу")
.DataValueField("StreetID")
.DataTextField("StreetName")
.DataSource(ds => ds
.Read(read => read.Action("GetStreetsDropDownList", "House")
.Data("getParentId"))
.ServerFiltering(true))
.AutoBind(false)
                                                 
))
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Прошу помощи
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]