Hi All,
I've been trying to make the Specification Attribute Option on the product page editable inline.
I created an Editor that renders a Telerik Listbox with the available options in(works if I hard code a SpecificationAttributeId to test), but cannot find how, or even if possible to relate this to the specific specification attribute on that row.
This is what I have so far.
Changed ProductSpecificationAttributeModel and updated controllers where appropriate to populate the values. [NopResourceDisplayName("Admin.Catalog.Products.SpecificationAttributes.Fields.SpecificationAttributeOption")]
//[AllowHtml]
[UIHint("AttributeOption")]
public string SpecificationAttributeOptionName { get; set; }
public int SpecificationAttributeId { get; set; }
Created a new editor template in Admin\Views\Product\EditorTemplates called AttributeOption.cshtml
@using Telerik.Web.Mvc.UI;
@using Nop.Core.Domain.Catalog;
@using Nop.Services.Catalog;
@{
var attributeId = Convert.ToInt32(ViewData["attributeId"].ToString());
var _specificationAttributeService = EngineContext.Current.Resolve<ISpecificationAttributeService>();
var allAttributeOptions = _specificationAttributeService.GetSpecificationAttributeOptionsBySpecificationAttribute(attributeId);
var attributesList = new List<SelectListItem>();
foreach (var pa in allAttributeOptions)
{
var item = new SelectListItem()
{
Text = pa.Name,
Value = pa.Id.ToString()
};
attributesList.Add(item);
}
}
@Html.Telerik().DropDownList().Name("SpecificationAttributeOptionName").BindTo(attributesList)
It all works upto this point.
Updated the Admin\Views\Product\CreateOrUpdate.cshtml
columns.Bound(x => x.SpecificationAttributeOptionName).Width(200).EditorViewData(new { attributeId = 1 });
This is the bit I cannot figure out (to replace the hard coded 1), to pass the current specification attribute id for the current row, I have added it to the ProductSpecificationAttributeModel model, and it’s being populated.
Thanks for any advice.
Paul