ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Discount/_CreateOrUpdate.TabHistory.cshtml
@model DiscountModel
@inject AdminAreaSettings adminAreaSettings
@{
    <vc:admin-widget widget-zone="discount_details_history_top" additional-data="Model" />
    <div id="usagehistory-grid"></div>
    <vc:admin-widget widget-zone="discount_details_history_bottom" additional-data="Model" />
    <script>
        $(document).ready(function () {
            $("#usagehistory-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("UsageHistoryList", "Discount", new { discountId = Model.Id }))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("UsageHistoryDelete", "Discount"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors",
                        model: {
                            id: "Id",
                            fields: {
                                //do not implicitly specify all fields
                                //we do it only for fields which implicitly require it
                                //otherwise, they'll be formatted wrong way
                                CreatedOn: {type: "date" }
                            }
                        }
                    },
                    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: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "CreatedOn",
                    title: "@T("Admin.Promotions.Discounts.History.CreatedOn")",
                    width: 200,
                    type: "date",
                    format: "{0:G}"
                }, {
                    field: "OrderId",
                    title: "@T("Admin.Promotions.Discounts.History.Order")",
                    width: 200,
                    template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Order")/#=OrderId#"><i class="fa fa-search"></i> #=OrderNumber# - @T("Admin.Common.View")</a>'
                }, {
                    field: "OrderTotal",
                    title: "@T("Admin.Promotions.Discounts.History.OrderTotal")",
                    width: 200
                },{
                    command: {name: "destroy", text: "@T("Admin.Common.Delete")"},
                    title: "@T("Admin.Common.Delete")",
                    width: 100
                }]
            });
        });
    </script>
}