ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/News/List.cshtml
@model NewsItemListModel
@inject AdminAreaSettings adminAreaSettings
@{
 
    //page title
    ViewBag.Title = T("Admin.ContentManagement.News.NewsItems").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption">
                    <i class="fa fa-hacker-news"></i>
                    @T("Admin.ContentManagement.News.NewsItems")
                </div>
                <div class="actions btn-group btn-group-devided">
                    <a href="@Url.Action("Create")" class="btn green"><i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @T("Admin.Common.AddNew") </span></a>
                    <vc:admin-widget widget-zone="news_list_buttons" additional-data="null" />
                </div>
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="form-group">
                            <admin-label asp-for="SearchStoreId" />
                            <div class="col-md-4 col-sm-6">
                                <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores" />
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <div class="row">
                            <div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">
                                <button class="btn btn-success filter-submit" id="search-newsitem">
                                    <i class="fa fa-search"></i> @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="x_content">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="newsitem-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#newsitem-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("List", "News"))",
                        type: "POST",
                        dataType: "json",
                        data: additionalData
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                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: "Title",
                width: 300,
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.Title")",
                template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Title)#</a>',
            }, {
                field: "Comments",
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.Comments")",
                width: 200,
                template: '<a class="k-link" href="Edit/#=Id#">@T("Admin.ContentManagement.News.NewsItems.Fields.Comments") - #=Comments# </a>'
            }, {
                field: "StartDate",
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.StartDate")",
                width: 150,
                type: "date",
                format: "{0:G}"
            }, {
                field: "EndDate",
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.EndDate")",
                width: 150,
                type: "date",
                format: "{0:G}"
            }, {
                field: "Published",
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.Published")",
                width: 100,
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                field: "CreatedOn",
                title: "@T("Admin.ContentManagement.News.NewsItems.Fields.CreatedOn")",
                width: 200,
                type: "date",
                format: "{0:G}"
            }]
        });
    });
</script>
<script>

    $(document).ready(function () {
        //search button
        $('#search-newsitem').click(function () {
            //search
            var grid = $('#newsitem-grid').data('kendoGrid');
            grid.dataSource.page(1); //new search. Set page size to 1
            //grid.dataSource.read(); we already loaded the grid above using "page" function
            return false;
        });
    });

    function additionalData() {
        var data = {
            SearchStoreId: $('#SearchStoreId').val()
        };
        addAntiForgeryToken(data);
        return data;
    }
</script>
