ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/CustomerReminder/_ConditionCategory.cshtml
@model CustomerReminderModel.ConditionModel
    @if (String.IsNullOrEmpty(Model.Id))
    {
        <div class="note note-info">
            @T("Admin.Customers.CustomerReminder.Condition.SaveBeforeEdit")
        </div>
    }
    @if (!String.IsNullOrEmpty(Model.Id))
    {
        <div class="panel panel-default">
            <div class="panel-body">
                <div id="categories-grid"></div>
            </div>
            <div class="panel-footer">
                <input type="submit" id="btnAddNewCategory" value="@T("Admin.Customers.CustomerReminder.Condition.Category.AddNew")" onclick="javascript:OpenWindow('@(Url.Action("CategoryAddPopup", "CustomerReminder", new { customerReminderId = Model.CustomerReminderId, conditionId = Model.Id, btnId = "btnRefreshCategories", formId = "customer-reminder-condition-form"}))', 800, 800, true); return false;" class="btn default" />
                <input type="submit" id="btnRefreshCategories" style="display: none" />
            </div>
        </div>

                <script>
                        $(document).ready(function () {
                            $("#categories-grid").kendoGrid({
                                dataSource: {
                                    transport: {
                                        read: {
                                            url: "@Html.Raw(Url.Action("ConditionCategory", "CustomerReminder", new { customerReminderId = Model.CustomerReminderId, conditionId = Model.Id }))",
                                            type: "POST",
                                            dataType: "json",
                                            data: addAntiForgeryToken
                                        },
                                        destroy: {
                                            url: "@Html.Raw(Url.Action("ConditionDeletePosition", "CustomerReminder", new { customerReminderId = Model.CustomerReminderId, conditionId = Model.Id }))",
                                            type: "POST",
                                            dataType: "json",
                                            data: addAntiForgeryToken,
                                        }
                                    },
                                    schema: {
                                        data: "Data",
                                        total: "Total",
                                        errors: "Errors",
                                        model: {
                                            id: "Id",
                                            fields: {
                                                CategoryName: {editable: false, type: "string" },
                                                CategoryId: { 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: "CategoryName",
                                    title: "@T("Admin.Customers.CustomerReminder.Condition.Fields.CategoryName")",
                                    template: '<a class="k-link" href="@Url.Action("Edit", "Category")/#=Id#">#=kendo.htmlEncode(CategoryName)#</a>',
                                },  {
                                    command: [{
                                        name: "destroy",
                                        text: "@T("Admin.Common.Delete")"
                                    }],
                                    width: 150
                                }]
                            });
                        });
                </script>
                    <script>
                        $(document).ready(function () {
                            $('#btnRefreshCategories').click(function () {
                                var grid = $("#categories-grid").data('kendoGrid');
                                grid.dataSource.read();
                                return false;
                            });
                        });
                    </script>

    }