ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Customer/_CreateOrUpdate.TabAddresses.cshtml
@model CustomerModel
@inject AdminAreaSettings adminAreaSettings
<div class="panel panel-default">
    <vc:admin-widget widget-zone="customer_details_addresses_top" additional-data="Model" />
    <div class="panel-body">
        <div id="customer-addresses-grid"></div>
    </div>
    <div class="panel-footer">
        <button type="button" class="k-button" onclick="location.href='@Url.Action("AddressCreate", new { customerId = Model.Id })'"><i class="fa fa-plus"></i>&nbsp;@T("Admin.Customers.Customers.Addresses.AddButton")</button>
    </div>
    <vc:admin-widget widget-zone="customer_details_addresses_bottom" additional-data="Model" />
</div>

<script>
$(document).ready(function () {
    $("#customer-addresses-grid").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "@Html.Raw(Url.Action("AddressesSelect", "Customer", new { customerId = Model.Id }))",
                    type: "POST",
                    dataType: "json",
                    data: addAntiForgeryToken
                },
                destroy: {
                    url: "@Html.Raw(Url.Action("AddressDelete", "Customer", new { customerId = Model.Id }))",
                    type: "POST",
                    dataType: "json",
                    data: addAntiForgeryToken
                }
            },
            schema: {
                data: "Data",
                total: "Total",
                errors: "Errors",
                model: {
                    id: "Id"
                }
            },
            error: function(e) {
                display_kendoui_grid_error(e);
                // Cancel the changes
                this.cancelChanges();
            },
            pageSize: @(adminAreaSettings.DefaultGridPageSize),
        },
        pageable: {
            refresh: true,
            pageSizes: [@(adminAreaSettings.GridPageSizes)]
        },
        editable: {
            confirmation: true,
            mode: "inline"
        },
        scrollable: false,
        columns: [{
            field: "FirstName",
            title: "@T("Admin.Address.Fields.FirstName")"
        }, {
            field: "LastName",
            title: "@T("Admin.Address.Fields.LastName")"
        }, {
            field: "Email",
            title: "@T("Admin.Address.Fields.Email")"
        }, {
            field: "PhoneNumber",
            title: "@T("Admin.Address.Fields.PhoneNumber")",
            minScreenWidth: 1020,
        }, {
            field: "AddressHtml",
            title: "@T("Admin.Address")",
            encoded: false
        }, {
            field: "Id",
            title: "@T("Admin.Common.Edit")",
            width: 100,
            template: '<a class="k-button" href="@Url.Action("AddressEdit", "Customer")?customerId=@Model.Id&addressid=#=Id#"><span class="k-icon k-i-edit"></span>&nbsp;&nbsp;@T("Admin.Common.Edit")</a>'
        }, {
            command: { name: "destroy", text: "@T("Admin.Common.Delete")" },
            title: "@T("Admin.Common.Delete")",
            width: 100
        }]
    });
});
</script>