ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/ShoppingCart/_CurrentCarts.TabCurrentCarts.cshtml
@inject AdminAreaSettings adminAreaSettings

<div class="panel panel-default">
    <div class="panel-body">
        <div id="carts-grid"></div>
    </div>
</div>
<script>
$(document).ready(function() {
    $("#carts-grid").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "@Html.Raw(Url.Action("CurrentCarts", "ShoppingCart"))",
                    type: "POST",
                    dataType: "json",
                    data: addAntiForgeryToken
                }
            },
            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)]
        },
        //details grid
        detailInit: detailInitCart,
        scrollable: false,
        columns: [
            {
                field: "CustomerId",
                title: "@T("Admin.CurrentCarts.Customer")",
                template: '<a href="@Url.Action("Edit", "Customer")/#=CustomerId#">#:CustomerEmail#</a>'
            }, {
                field: "TotalItems",
                title: "@T("Admin.CurrentCarts.TotalItems")",
                width: 150
            }
        ]
    });
});

//details grid
function detailInitCart(e) {
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "@Html.Raw(Url.Action("GetCartDetails", "ShoppingCart"))?customerId="+e.data.CustomerId,
                    type: "POST",
                    dataType: "json",
                    data: addAntiForgeryToken
                }
            },
            schema: {
                data: "Data",
                total: "Total",
                errors: "Errors"
            },
            error: function(e) {
                display_kendoui_grid_error(e);
                // Cancel the changes
                this.cancelChanges();
            },
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        },
        scrollable: false,
        sortable: true,
        pageable: {
            refresh: true,
            numeric: false,
            previousNext: false,
            info: false
        },
        columns: [
            {
                field: "ProductName",
                title: "@T("Admin.CurrentCarts.Product")",
                template: '<a href="@Url.Action("Edit", "Product")/#=ProductId#">#:ProductName#</a>' +
                    '# if(AttributeInfo && AttributeInfo.length > 0) {# <br />#=AttributeInfo# #} #',
                width: 400
            },{
                field: "Quantity",
                title: "@T("Admin.CurrentCarts.Quantity")",
                width: 150
            },{
                field: "UnitPrice",
                title: "@T("Admin.CurrentCarts.UnitPrice")",
                width: 150
            },{
                field: "Total",
                title: "@T("Admin.CurrentCarts.Total")",
                width: 150
            },{
                field: "Store",
                title: "@T("Admin.CurrentCarts.Store")",
                width: 150
            },{
                field: "UpdatedOn",
                title: "@T("Admin.CurrentCarts.UpdatedOn")",
                width: 150,
                type: "date",
                format: "{0:G}"
            }
        ]
    });
}
</script>
