@page
@model NorthwindRazor.Pages.Products_ListMultipleDeleteModel
@{
    ViewData["Title"] = "List of Products";
}
 
@section AdditionalCss {
    <link rel="stylesheet" href="~/css/ui.jqgrid.min.css" />
}
 
@section AdditionalJavaScript {
    <script src="~/js/jqgrid-i18n/grid.locale-en.min.js" asp-append-version="true"></script>
    <script src="~/js/jquery-jqgrid-4.13.2.min.js" asp-append-version="true"></script>
    <script src="~/js/jqgrid-listmultipledelete.js" asp-append-version="true"></script>
 
    <script type="text/javascript">
        var urlAndMethod = '/Products/Products_ListMultipleDelete/';
 
        $(function () {
            $('#list-grid').jqGrid({
                url: '/Products/Products_ListMultipleDelete?handler=GridData',
                datatype: 'json',
                mtype: 'GET',
                colNames: ['Product ID','Product Name','Supplier ID','Category ID','Quantity Per Unit','Unit Price','Units In Stock','Units On Order','Reorder Level','Discontinued'],
                colModel: [
                    { name: 'ProductID', index: 'ProductID', align: 'right' },
                    { name: 'ProductName', index: 'ProductName', align: 'left' },
                    { name: 'SupplierID', index: 'SupplierID', align: 'right' },
                    { name: 'CategoryID', index: 'CategoryID', align: 'right' },
                    { name: 'QuantityPerUnit', index: 'QuantityPerUnit', align: 'left' },
                    { name: 'UnitPrice', index: 'UnitPrice', align: 'right', formatter: 'currency', formatoptions: { decimalPlaces: 2, prefix: "$"} },
                    { name: 'UnitsInStock', index: 'UnitsInStock', align: 'right', formatter: 'integer' },
                    { name: 'UnitsOnOrder', index: 'UnitsOnOrder', align: 'right', formatter: 'integer' },
                    { name: 'ReorderLevel', index: 'ReorderLevel', align: 'right', formatter: 'integer' },
                    { name: 'Discontinued', index: 'Discontinued', align: 'center', formatter: 'checkbox' },
                ],
                pager: $('#list-pager'),
                rowNum: 10,
                pageable: true,
                jsonReader:
                {
                    page: "d.page"
                },
                rowList: [5, 10, 20, 50],
                sortname: 'ProductID',
                sortorder: "asc",
                viewrecords: true,
                caption: 'List of Products',
                height: '100%',
                width: '1200',
                toolbar: [true'top'],
                multiselect: true,
                onSelectRow: function (idstatuse) {
                    // determine if a checkbox was clicked instead of the row
                    var isCheckBoxClicked = $(e.target).is('input:checkbox');
 
                    // if the row is clicked go to the update page
                    if (!isCheckBoxClicked) {
                        if (id != null) {
                            window.location.href = '/Products/Products_Update?id=' + id + '&returnUrl=/Products/Products_ListMultipleDelete';
                        }
                    }
                }
            });
 
            // add the delete link (trash icon) to the jqgrid.
            $('#list-grid').append("<a href='#' id='deleteMultiple' onclick='deleteItems();return false;'><img src='../images/Delete.png' alt='Delete Selected Items' style='border: none;' /></a>");
        });
 
        // rename the page parameter to _page because asp.net core razor's page model
        // does not recognize the page parameter when passed
        $.extend(jQuery.jgrid.defaults, {
            prmNames: {
                page: "_page"
            }
        });
    </script> 
}
 
<h2>@ViewData["Title"]</h2>
<br /><br />
<div id="errorConfirmationDialog"></div>
<div id="errorDialog"></div>
 
<a href="/Products/Products_Add?returnUrl=/Products/Products_ListMultipleDelete"><img src="@Url.Content("~/images/Add.gif")" alt="Add New Products" style="bordernone;" /></a>&nbsp;<a href="/Products/Products_Add?returnUrl=/Products/Products_ListMultipleDelete">Add New Products</a>
<br /><br />
 
<table id="list-grid"></table>
<div id="list-pager"></div>