asp.net-mvc – 在nopcommerce 2.8中使用Telerik插件的自定义网
发布时间:2020-12-16 07:40:29 所属栏目:asp.Net 来源:网络整理
导读:我正在研究nopcommerce2.8版本.我有一个telerik插件实现的问题来创建新的网格. 我实施了一个概念,我希望为不同的客户提供不同价格的产品.因此,要为不同的客户分配新价格,请在管理面板中使用telerik在编辑产品变量页面中创建网格.我创建了一个新选项卡来显示
我正在研究nopcommerce2.8版本.我有一个telerik插件实现的问题来创建新的网格.
我实施了一个概念,我希望为不同的客户提供不同价格的产品.因此,要为不同的客户分配新价格,请在管理面板中使用telerik在编辑产品变量页面中创建网格.我创建了一个新选项卡来显示这些详细信息.我能够在网格中显示客户名称和价格,但是当我在编辑一行后点击更新按钮时,我无法调用更新功能.同样的更新功能我也要求删除网格行,所以当我点击删除相同的更新功能获取触发器.我认为在View中错过了一些设置.请帮我解决这个更新问题. 我的nopcommerce的模型,视图和控制器如下所示. 谢谢. //Model using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; using FluentValidation.Attributes; using Nop.Admin.Models.Customers; using Nop.Admin.Validators.Catalog; using Nop.Web.Framework; using Nop.Web.Framework.Localization; using Nop.Web.Framework.Mvc; using Telerik.Web.Mvc; namespace Nop.Admin.Models.Catalog { public partial class CustomerProductPriceModel : BaseNopModel { public int Customer_Id { get; set; } [NopResourceDisplayName("Customer Name")] public string Customer_name { get; set; } [NopResourceDisplayName("Price")] public decimal Price { get; set; } [NopResourceDisplayName("Unit")] public string Units { get; set; } } } // view @(Html.Telerik().Grid<CustomerProductPriceModel>() .Name("Grid") .DataKeys(x => { x.Add(y => y.Customer_Id); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("CustomerProductPriceList","ProductVariant",new { productVariantId = Model.Id }) .Update("CustomerPriceUpdate",new { productVariantId = Model.Id }) .Delete("CustomerPriceUpdate",new { productVariantId = Model.Id }); }) .Columns(columns => { columns.Bound(y => y.Customer_name).Width(200).ReadOnly(); columns.Bound(y => y.Price).Width(100); columns.Command(commands => { commands.Edit().Text(T("Admin.Common.Edit").Text); commands.Delete().Text(T("Admin.Common.Delete").Text); }).Width(180); }) .Editable(x => { x.Mode(GridEditMode.InLine); }) .EnableCustomBinding(true) ) // controller [GridAction(EnableCustomBinding = true)] public ActionResult CustomerPriceUpdate(GridCommand command,CustomerProductPriceModel model,int productVariantId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) return AccessDeniedView(); return CustomerProductPriceList(command,productVariantId); } [HttpPost,GridAction(EnableCustomBinding = true)] public ActionResult CustomerProductPriceList(GridCommand command,int productVariantId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) return AccessDeniedView(); var productVariant = _productService.GetProductVariantById(productVariantId); if (productVariant == null) throw new ArgumentException("No product variant found with the specified id"); var CustomerPrices = PrepareCustomerProductPriceModel(productVariant.Product.Id); var CustomerPricesa = CustomerPrices .Select(x => { return new CustomerProductPriceModel() { Customer_Id = x.Customer_Id,Price = x.Price,Units = x.Units,Customer_name = x.Customer_name }; }) .ToList(); var model = new GridModel<CustomerProductPriceModel> { Data = CustomerPricesa,Total = CustomerPrices.Count }; return new JsonResult { Data = model }; } 解决方法
是否有理由不使用nopCommerce中已有的内置客户价格水平,或者您想一次显示所有价格?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – Razor中的Direct Model.Property与Html Hel
- 如何在asp.net中检测服务器端的浏览器关闭?
- asp.net-mvc-3 – 带区域的MVC – Html.ActionLink返回错误
- asp.net-mvc – IIS7 – 密码保护开发服务器
- asp.net – 如何从身体绑定时自定义模型绑定器?
- asp.net-core – 使用Scaffold-DBContext设置数据库优先EF项
- asp.net-core – VSTS – 构建ASP.NET Core 2.0应用程序失败
- asp.net-mvc – Elmah.Mvc 2.0自定义身份验证
- 如何添加自定义属性到ASP.NET控件
- asp.net-mvc – 为什么ASP.NET MVC Html.CheckBox输出两个I
推荐文章
站长推荐
- asp.net-mvc-4 – 如何永久教Visual Studio检测我
- asp.net – 在TableRowCollection上使用linq
- asp.net-mvc-3 – 为mvc创建一个html帮助器
- asp.net-mvc – 通配符在asp.net mvc路由
- asp.net-mvc – 在ASP.NET Core 1.1中配置基本身
- asp.net – 在Web.config帮助中定义tagPrefixes
- 突出显示ASP.Net菜单中的选定选项卡
- asp.net-mvc – 在应用程序洞察中设置用户名
- 如何设置文本框的值textmode = date ASP.NET C#
- ASP.NET Core的配置(5):配置的同步[ 实例篇]
热点阅读