ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/News/_CreateOrUpdate.TabComments.cshtml
@model NewsItemModel
@inject AdminAreaSettings adminAreaSettings
<vc:admin-widget widget-zone="news_comments_list" additional-data="Model" />
@if (!String.IsNullOrEmpty(Model.Id))
{
    <div class="panel panel-default">
        <vc:admin-widget widget-zone="news_details_comments_top" additional-data="Model" />
        <div class="panel-body">
            <div id="comments-grid"></div>
        </div>
        <vc:admin-widget widget-zone="news_details_comments_bottom" additional-data="Model" />
    </div>
    <script>
        $(document).ready(function () {
            $("#comments-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Url.Action("Comments", "News", new { filterByNewsItemId = Model.Id })",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("CommentDelete", "News"))",
                            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: true,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "CustomerId",
                    title: "@T("Admin.ContentManagement.News.Comments.Fields.Customer")",
                    width: 200,
                    template: '<a class="k-link" href="@Url.Action("Edit", "Customer")/#=CustomerId#">#:kendo.htmlEncode(CustomerInfo)#</a>'
                }, {
                    field: "CommentTitle",
                    title: "@T("Admin.ContentManagement.News.Comments.Fields.CommentTitle")"
                }, {
                    field: "CommentText",
                    title: "@T("Admin.ContentManagement.News.Comments.Fields.CommentText")",
                    encoded: false
                }, {
                    field: "CreatedOn",
                    title: "@T("Admin.ContentManagement.News.Comments.Fields.CreatedOn")",
                    width: 200,
                    type: "date",
                    format: "{0:G}"
                }, {
                    command: { name: "destroy", text: "@T("Admin.Common.Delete")" },
                    title: "@T("Admin.Common.Delete")",
                    width: 100
                }]
            });
        });
    </script>
}
else
{
    <div class="note note-info">
        @T("Admin.ContentManagement.News.NewsItems.SaveBeforeEdit")
    </div>
}