Product Secification Attributes - Inline Editing of Options

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
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
10 years ago
Thought I would update my own question.

What I tried above, would never have worked!!! It mixes client and server processing.

Have solved it though after a few hours reading forum posts, blogs etc. It is actually quite easy, and got most of it done quite quickly, but it was this blog article that turned the light bulb on.

http://mvc3only.blogspot.co.uk/2012/04/teleik-mvc-grid-ajax-edit-and-drop-down.html

I pretty much followed this article, changing it to suite my specific requirements.

It was the things to remember bit at the bottom 3), that finally lead to it being solved.

Due to this issue https://www.nopcommerce.com/boards/t/23518/critical-security-issue-fix-for-all-2x-versions.aspx
Removing the Telerik references "<add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />" seems to stop all the correct libraries being loaded to run the Telerik client side Javascript correctly.

I am working on nopcommerce Version 3.0 and this line is removed (By design I assume), anyway adding it back and all worked perfectly.

This leads me to another question, which is, is there a way around this without re-introducing the vulnerability. Perhaps by manually adding the JavaScript libraries for Telerik. I will ask this on the Thread about the Vulnerability.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.