ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/OrderTags/List.cshtml
@inject AdminAreaSettings adminAreaSettings

@{ 
    //page title
    ViewBag.Title = T("Admin.Orders.OrderTags").Text;
}
<form asp-area="@Constants.AreaAdmin" asp-controller="OrderTags" method="post" id="order-tags-form">

<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-cubes"></i>
                    @T("Admin.Orders.OrderTags")
                </div>
                <vc:admin-widget widget-zone="order_tag_list_buttons" additional-data="null" />
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="x_content">
                        <div id="order-tags-grid"></div>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<script>
    $(document).ready(function () {
            $("#order-tags-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("List", "OrderTags"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("Delete", "OrderTags"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors",
                        model: {
                            id: "Id",
                            fields: {
                                Name: { editable: true, type: "string" },
                                Value: { editable: true, type: "string" },
                                Store: { editable: true, type: "string" },
                                StoreId: { editable: true, type: "string" },
                                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();
                    },
                    pageSize: @(adminAreaSettings.DefaultGridPageSize),
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    pageSizes: [@(adminAreaSettings.GridPageSizes)]
                },
                editable: {
                    confirmation: true,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "Name",
                    title: "@T("Admin.Orders.OrderTags.Fields.Name")",
                    width: 300,
                    template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>',
                }, {
                    field: "OrderCount",
                    title: "@T("Admin.Orders.ProductTags.Fields.OrderCount")",
                    width: 100,
                    headerAttributes: { style: "text-align:center" },
                    attributes: { style: "text-align:center" },
                }, {
                    command: { name: "destroy", text: "@T("Admin.Common.Delete")" },
                    title: "@T("Admin.Common.Delete")",
                    width: 100
                }]
            });
        });
</script>
