@model RazorApp.ViewModels.ShoppingCartViewModel
@{
ViewBag.Title = "Shopping Cart";
}
<script type="text/javascript">
$(function () {
var requestUrl = '@Url.Action("GetCart")';
$("#cartResults").jqGrid({
url: requestUrl,
datatype: 'json',
mtype: 'POST',
emptyrecords: "No results",
colNames: ['Album Name', 'Price', 'Quantity', ''],
colModel: [
{ name: "Title", width: 350, editable: false, searchoptions: {}, index: "Title" },
{ name: "Price", width: 100, editable: false, searchoptions: {}, index: "Price" },
{ name: "Quantity", width: 100, editable: false, searchoptions: {}, index: "Quantity" },
{ name: 'Delete', width: 140, formatter: deleteFormatter }
],
pager: $('#cartPager'),
rowList: [], // disable page size dropdown
pgbuttons: false, // disable page control like next, back button
viewrecords: false, // disable current view record text like 'View 1-10 of 100'
sortname: 'id',
sortorder: 'asc',
loadonce: false,
sortable: true,
scrollrows: true,
height: 300,
pgtext: null,
hoverrows: false,
footerrow: true,
userDataOnFooter: true,
emptyDataText: "Your Cart is Empty",
gridComplete: function () {
if ($('#cartResults').getGridParam('records') == 0) {
//var noRecords = "<div class=\"loading ui-state-default ui-state-active\" id=\"load_forSteps_Home_table\" style=\"left: 0px; top: 48px; display: block;\"><div class=\"field-validation-error\" style=\"padding:12px 4px 4px 4px\">Your Cart is Empty.</div></div>";
var noRecords = "<div class=\"customloading\" id=\"load_cart_Results\" style=\"left: 0px; top: 48px; display: block;\"><div class=\"ui-state-highlight ui-corner-all\" style=\"margin-top: 20px; padding: 0 .7em;width: 500px;height:200px\">";
noRecords += "<p><span class=\"ui-icon ui-icon-info\" style=\"float: left; margin-right: .3em;\"></span><strong>No records</strong><br /><br /><br />";
noRecords += "Your Cart is Empty. Select albums to your cart.</p></div></div>";
$('#lui_cartResults', '.ui-jqgrid').after($(noRecords));
$('#btnCheckOut').hide();
} $("button").button();
$(".RemoveLink").click(function () {
// Get the id from the link
var recordToDelete = $(this).attr("data-id");
if (recordToDelete != '') {
// Perform the ajax post
$.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete },
function (data) {
$('p', '#update-message-disp').append(data.Message);
$('#update-message-disp').show("slow");
$('#cartResults').trigger("reloadGrid");
return false;
});
}
});
}
});
function deleteFormatter(cellvalue, options, rowObject) {
return "<button class=\"RemoveLink\" data-id = \"" + options.rowId + "\">Remove from Cart</button>";
}
$('#update-message-disp').hide();
});
</script>
<div class="styler">
<fieldset class="ui-widget">
<legend class="ui-state-legend-default ui-corner-top ui-corner-bottom">Review Your Cart</legend>
<div id="update-message-disp" class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;width: 500px">
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span><strong>Cart modified</strong><br />
</p>
</div>
<br />
<table id="cartResults">
</table>
<div id="cartPager">
</div>
</fieldset>
@Html.ActionLink("Checkout>>", "AddressAndPayment", "Checkout", null, new { id = "btnCheckOut"})
</div>