我想修改管理订单列表视图以像当前购物车页面一样工作,即有一个详细信息视图,如果您打开订单的详细信息视图,它会显示订单中订购的商品本身。
为了实现这一点,我在代码中做了以下更改,但它无法正常工作!
@(Html.Telerik().Grid<OrderModel>()
.Name("orders-grid")
.ClientEvents(events => events
.OnDataBinding("onDataBinding")
.OnDataBound("onDataBound")
.OnComplete("onComplete"))
.Columns(columns =>
{
columns.Bound(x => x.Id)
.ClientTemplate("<input type='checkbox' name='checkedRecords'
value='<#= Id #>' class='checkboxGroups'/>")
.Title("<input id='mastercheckbox' type='checkbox'/>")
.Width(50)
.HtmlAttributes(new { style = "text-align:center" })
.HeaderHtmlAttributes(new { style = "text-align:center" });
columns.Bound(x => x.Id)
.Template(x => Html.ActionLink(x.CustomerEmail, "Details",
"Order", new { id = x.Id }, new { }))
.ClientTemplate("<a href=\"Edit/<#= Id #>\">" +
T("Admin.Common.View").Text + "</a>");
if (!Model.IsLoggedInAsVendor)
{
//a vendor does not see order details such statuses or
totals
columns.Bound(x => x.OrderStatus);
}
columns.Bound(x => x.PaymentStatus);
if (!Model.IsLoggedInAsVendor)
{
//a vendor does not see order details such statuses or
totals
columns.Bound(x => x.ShippingStatus);
}
columns.Bound(x => x.CustomerEmail);
columns.Bound(x => x.StoreName);
columns.Bound(x => x.CreatedOn);
if (!Model.IsLoggedInAsVendor)
{
//a vendor does not see order details such statuses or
totals
columns.Bound(x => x.OrderTotal)
.FooterTemplate(
string.Format("<div><strong>{0}:</strong></div>"
+
"<div>{1}: <span id=\"aggregator-
profit-block\"></span></div>" +
"<div>{2}: <span id=\"aggregator-
tax-block\"></span></div>" +
"<div>{3}: <span id=\"aggregator-
total-block\"></span></div>",
T("Admin.Orders.Report.Summary").Text,
T("Admin.Orders.Report.Profit").Text,
T("Admin.Orders.Report.Tax").Text,
T("Admin.Orders.Report.Total").Text));
}
columns.Bound(x => x.Id)
.Template(x => Html.ActionLink(T("Admin.Common.View").Text,
"Edit", new { id = x.Id }))
.ClientTemplate("<a href=\"Edit/<#= Id #>\">" +
T("Admin.Common.View").Text + "</a>")
.Width(50)
.Centered()
.Title(T("Admin.Common.View").Text);
})
.DetailView(details => details.ClientTemplate(
Html.Telerik().Grid<OrderModel.OrderProductVariantModel>()
.Name("cartitems-grid-<#= Order Id #>")
.Columns(columns =>
{
columns.Bound(sci => sci.FullProductName)
.Template(sci => Html.ActionLink(sci.FullProductName,
"Edit", "ProductVariant", new { id = sci.ProductVariantId }, new { }))
.ClientTemplate("<a href=\""+
@Url.Content("~/Admin/ProductVariant/Edit/") + "<#= ProductVariantId #>\"><#=
FullProductName #></a>");
columns.Bound(sci => sci.Quantity).Width(100);
columns.Bound(sci => sci.UnitPriceInclTax).Width(100);
columns.Bound(sci => sci.SubTotalInclTax).Width(100);
// columns.Bound(sci => sci.Store).Width(150);
// columns.Bound(sci => sci.UpdatedOn).Width(100);
})
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("GetOrderDetails", "Order", new
{
OrderId =
"<#= OrderId #>"
}))
.ToHtmlString()
)
)
.Pageable(settings =>
settings.PageSize(gridPageSize).Position(GridPagerPosition.Both))
.DataBinding(dataBinding => dataBinding.Ajax().Select("OrderList",
"Order"))
.EnableCustomBinding(true))
我试图通过OrdersProductVariantModel从部分OrdersModel类中获取数据以显示此数据
我修改了OrderController以包含以下方法
[GridAction(EnableCustomBinding = true)]
public ActionResult GetOrderDetails(int OrderId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrentCarts))
return AccessDeniedView();
// var customer = _customerService.GetCustomerById(customerId);
// var cart = customer.ShoppingCartItems.Where(x => x.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
var order = _orderService.GetOrderById(OrderId);
var orderDetails = order.OrderProductVariants.ToList();
var gridModel = new GridModel<OrderModel.OrderProductVariantModel>()
{
// Data = cart.Select(sci =>
Data = orderDetails.Select(sci =>
{
// decimal taxRate;
// var store = _storeService.GetStoreById(sci.StoreId);
var sciModel = new OrderModel.OrderProductVariantModel()
{
Id = sci.Id,
// Store = store != null ? store.Name : "Unknown",
ProductVariantId = sci.ProductVariantId,
Quantity = sci.Quantity,
FullProductName = sci.ProductVariant.FullProductName,
// UnitPrice = _priceFormatter.FormatPrice(_taxService.GetProductPrice(sci.ProductVariant, _priceCalculationService.GetUnitPrice(sci, true), out taxRate)),
// Total = _priceFormatter.FormatPrice(_taxService.GetProductPrice(sci.ProductVariant, _priceCalculationService.GetSubTotal(sci, true), out taxRate)),
// UpdatedOn = _dateTimeHelper.ConvertToUserTime(sci.UpdatedOnUtc, DateTimeKind.Utc)
};
return sciModel;
}),
// Total = cart.Count
};
return new JsonResult
{
Data = gridModel
};
}
但是,当我运行代码时,它甚至会停止加载订单,因为列表页面上根本没有任何活动!
有人可以帮我解决这个问题吗?
由于 阿米特。