I've a Contact page, where a user can maintain it. Using Kendo grid, I listed the contact on my initial grid with only few columns. When the user clicks edit button, a PopUp comes up so edit/delete can be performed. However, the contact table has 3 foreign keys (AccountId, StateProvinceId, CountryRegionId) that show up as dropdown list on the main grid but not on the PopUp window. How can I populate these dropdown on Popup edit mode and disable some fields?

@model Streck.Stats.Web.Models.ContactModel
@using Streck.Stats.Web.Helpers;
@using System.Collections;

<div>
@(Html.Kendo().Grid<ContactModel>()
    .Name(Constants.ContactGridId)
    .EnableCustomBinding(true)
    .Sortable()
    .Columns(c =>
    {
        c.Bound(e => e.ContactId).Width(50);
        c.ForeignKey(e => e.AccountId, (IEnumerable)ViewData["Account"], "AccountId", "Name").Title("Account");
        c.Bound(e => e.PrimaryContact);
        c.Bound(e => e.ReceivesNotifications);
        c.Bound(e => e.FirstName);
        c.Bound(e => e.LastName);
        c.Bound(e => e.Department).Hidden();
        c.Bound(e => e.Address1).Hidden();
        c.Bound(e => e.Address2).Hidden();
        c.Bound(e => e.City).Hidden();
        c.ForeignKey(e => e.StateProvinceId, (IEnumerable)ViewData["StateProvinces"], "StateProvinceId", "StateAbbName").Title("State Province").Hidden();
        c.Bound(e => e.Zip).Hidden();
        c.ForeignKey(e => e.CountryRegionId, (IEnumerable)ViewData["CountryRegions"], "CountryRegionId", "CountryCode").Title("Country Region").Hidden();
        c.Bound(e => e.Phone).Hidden();
        c.Bound(e => e.PhoneExtension).Hidden();
        c.Bound(e => e.Fax).Hidden();
        c.Bound(e => e.Email).Hidden();
        c.Command(command => { command.Edit(); command.Destroy(); }).Width(155);
    })
    .Events(events =>
    {
        events.Cancel("Helpers.HideNotificationArea");
    })
    .Sortable()
    .Selectable()
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditContact"))


    .Pageable()
    .Filterable()
    .ToolBar(items =>
    {
        items.Create().Text("Add New Contact");
    })
    .DataSource(d => d
        .Ajax()
        .ServerOperation(true)
        .PageSize(15)
        .Model(model =>
        {
            model.Id(m => m.ContactId);
            model.Field(m => m.ContactId).Editable(false);
            model.Field(m => m.AccountId).DefaultValue(-1);
            model.Field(m => m.PrimaryContact).DefaultValue(false);
            model.Field(m => m.ReceivesNotifications).DefaultValue(false);
            model.Field(m => m.FirstName);
            model.Field(m => m.LastName);
            model.Field(m => m.Department);
            model.Field(m => m.Address1);
            model.Field(m => m.Address2);
            model.Field(m => m.City);
            model.Field(m => m.StateProvinceId).DefaultValue(-1);
            model.Field(m => m.Zip);
            model.Field(m => m.CountryRegionId).DefaultValue(-1);
            model.Field(m => m.Phone);
            model.Field(m => m.PhoneExtension);
            model.Field(m => m.Fax);
            model.Field(m => m.Email);
        })

                .Read(read => read.Action("Read_Contacts", Constants.ContactController))
                .Create(create => create.Action("Create", Constants.ContactController))
                .Update(update => update.Action("Update", Constants.ContactController))
                .Destroy(destroy => destroy.Action("Delete", Constants.ContactController))
        .Events(events =>
        {
            events.Error("function(e){Helpers.GridError(e, '" + Constants.ContactGridId + "')}");
            events.Change(@<text>
                function(e) {
                Helpers.HideNotificationArea(e);
                Helpers.OnChangeForeignKeyRead(e, ['AccountId'],['StateProvinceId'],['CountryRegionId']);
                }
            </text>);
        })
            )
)

Related posts

Recent Viewed