ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Template/CategoryTemplates.cshtml
@{
    //page title
    ViewBag.Title = T("Admin.System.Templates.Category").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-tasks"></i>
                    @T("Admin.System.Templates.Category")
                </div>
                <vc:admin-widget widget-zone="category_template_list_buttons" additional-data="null" />
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="templates-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


    <script>
        $(document).ready(function () {
            $("#templates-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("CategoryTemplates", "Template"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        create: {
                            url: "@Html.Raw(Url.Action("CategoryTemplateAdd", "Template"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        update: {
                            url:"@Html.Raw(Url.Action("CategoryTemplateUpdate", "Template"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("CategoryTemplateDelete", "Template"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors",
                        model: {
                            id: "Id",
                            fields: {
                                Name: { editable: true, type: "string" },
                                ViewPath: { editable: true, type: "string" },
                                DisplayOrder: { editable: true, type: "number" },
                                Id: { editable: false, type: "string" }
                            }
                        }
                    },
                    requestEnd: function (e) {
                        if (e.type == "create" || e.type == "update") {
                            this.read();
                        }
                    },
                    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
                },
                toolbar: [{ name: "create", text: "@T("Admin.Common.AddNewRecord")" }],
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "Name",
                    title: "@T("Admin.System.Templates.Category.Name")",
                    width: 300
                }, {
                    field: "ViewPath",
                    title: "@T("Admin.System.Templates.Category.ViewPath")",
                    width: 300
                }, {
                    field: "DisplayOrder",
                    title: "@T("Admin.System.Templates.Category.DisplayOrder")",
                    //integer format
                    format: "{0:0}",
                    width: 100
                }, {
                    command: [{
                        name: "edit",
                        text: {
                            edit: "@T("Admin.Common.Edit")",
                            update: "@T("Admin.Common.Update")",
                            cancel: "@T("Admin.Common.Cancel")"
                        }
                    }, {
                        name: "destroy",
                        text: "@T("Admin.Common.Delete")"
                    }],
                    width: 200
                }]
            });
        });
    </script>
