ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/CustomerAction/_ConditionManufacturer.cshtml
@model CustomerActionConditionModel
    @if (String.IsNullOrEmpty(Model.Id))
    {
        <div class="note note-info">
            @T("Admin.Customers.CustomerActionCondition.SaveBeforeEdit")
        </div>
    }

    @if (!String.IsNullOrEmpty(Model.Id))
    {
        <div class="panel panel-default">
            <div class="panel-body">
                <div id="manufacturers-grid"></div>
            </div>
            <div class="panel-footer">
                <input type="submit" id="btnAddNewManufacturer" value="@T("Admin.Customers.CustomerActionCondition.Manufacturers.AddNew")" onclick="javascript:OpenWindow('@(Url.Action("ManufacturerAddPopup", "CustomerAction", new { customerActionId = Model.CustomerActionId, conditionId = Model.Id, btnId = "btnRefreshManufacturers", formId = "customer-action-condition-form" }))', 800, 800, true); return false;" class="btn default" />
                <input type="submit" id="btnRefreshManufacturers" style="display: none" />
            </div>
        </div>
    <script>
            $(document).ready(function () {
                $("#manufacturers-grid").kendoGrid({
                    dataSource: {
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("ConditionManufacturer", "CustomerAction", new { customerActionId = Model.CustomerActionId, conditionId = Model.Id }))",
                                type: "POST",
                                dataType: "json",
                                data: addAntiForgeryToken
                            },
                            destroy: {
                                url: "@Html.Raw(Url.Action("ConditionDeletePosition", "CustomerAction", new { customerActionId = Model.CustomerActionId, conditionId = Model.Id }))",
                                type: "POST",
                                dataType: "json",
                                data: addAntiForgeryToken
                            }
                        },
                        schema: {
                            data: "Data",
                            total: "Total",
                            errors: "Errors",
                            model: {
                                id: "Id",
                                fields: {
                                    ManufacturerName: {editable: false, type: "string" },
                                    ManufacturerId: {editable: false, type: "string" }
                                }
                            }
                        },
                        error: function(e) {
                            display_kendoui_grid_error(e);
                            // Cancel the changes
                            this.cancelChanges();
                        },
                        serverPaging: true,
                        serverFiltering: true,
                        serverSorting: true
                    },
                    pageable: {
                        refresh: true,
                        numeric: false,
                        previousNext: false,
                        info: false
                    },
                    editable: {
                        confirmation: false,
                        mode: "inline"
                    },
                    scrollable: false,
                    columns: [{
                        field: "ManufacturerName",
                        title: "@T("Admin.Customers.CustomerActionCondition.Fields.Manufacturer")",
                        template: '<a class="k-link" href="@Url.Action("Edit", "Manufacturer")/#=Id#">#=kendo.htmlEncode(ManufacturerName)#</a>',
                    }, {
                        command: [{
                            name: "destroy",
                            text: "@T("Admin.Common.Delete")"
                        }],
                        width: 150
                    }]
                });
            });
    </script>
            
        <script>
            $(document).ready(function () {
                $('#btnRefreshManufacturers').click(function () {
                    //refresh grid
                    var grid = $("#manufacturers-grid").data('kendoGrid');
                    grid.dataSource.read();
                    return false;
                });
            });
        </script>
              
    }