Changing Specification Attributes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 anos atrás
Greetings,

I'm currently trying to change how Specification Attributes work within Product Detail on the Admin side of Nop.  I would like to change the Attribute Option column to become a dropdownlist filled with the current Attribute's options when editing.  I know somehow I can add in a Editor Template but have yet to get to work correctly and thought I would see if anyone out in the community has a clue.  Any help would be appreciated.  Thanks.

Kindest Regards,
Chad Johnson
11 anos atrás
So I've isolated the problem down to something with jQuery and IE8 now.  I've verified that everything works going into the ajax, coming out of the ajax, and into the code afterwards.

The problem I now get is the following when the dropdownlist is trying to build:  "Error: Unexpected call to method or property access."

The error in debugger points to the following code in jQuery: this.nodeType===1&&this.appendChild(a)

In researching this issue, it appears jQuery and IE8 do not play well together on certain pieces.  I'm trying to figure out if there is another way of getting around this but am stumped at the moment.  Any help would be appreciated.

Here is what I have thus far.

Nop.Admin/Views/Product/_CreateOrUpdate.cshtml (in TabSpecificationAttributes())


                @(Html.Telerik().Grid<ProductSpecificationAttributeModel>()
                        .Name("specificationattributes-grid")
                        .DataKeys(x =>
                        {
                            x.Add(y => y.Id).RouteKey("psaId");
                        })
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.SpecificationAttributeOptionId).ReadOnly().Visible(false);
                            columns.Bound(x => x.SpecificationAttributeName).Width(200).ReadOnly();
                            columns.Bound(x => x.SpecificationAttributeOptionName).Width(200);
                            columns.Bound(x => x.AllowFiltering).Width(100);
                            columns.Bound(x => x.ShowOnProductPage).Width(100);
                            columns.Bound(x => x.DisplayOrder).Width(100);
                            columns.Command(commands =>
                            {
                                commands.Edit();
                                commands.Delete();
                            }).Width(180);

                        })
                        .Editable(x =>
                        {
                            x.Mode(GridEditMode.InLine);
                        })
                        .DataBinding(dataBinding =>
                        {
                            dataBinding.Ajax().Select("ProductSpecAttrList", "Product", new { productId = Model.Id })
                                .Update("ProductSpecAttrUpdate", "Product")
                                .Delete("ProductSpecAttrDelete", "Product");
                        })
                        .ClientEvents(events => events.OnEdit("onProductSpecificationAttributeOptionEdit"))
                        .EnableCustomBinding(true))
                </div>
                <script type="text/javascript">
                    function onProductSpecificationAttributeOptionEdit(e) {
                        $.getJSON('@Url.Action("GetSpecificationAttributeOptionNames", "Product")', { selectedId: e.dataItem.SpecificationAttributeOptionId }, function (data) {
                            var ddl = $('#SpecificationAttributeOptionName');
                            ddl.html("");
                            var options = "";
                            $.each(data, function (index, item) {
                                options += "<OPTION value='" + item.Value + "'>" + item.Text + "</OPTION>";
;
                            });
                            ddl.html(options);
                        });
                    }
                </script>


EditorTemplates/ProductSpecificationAttributeOptions.cshtml


@model string
@using Telerik.Web.Mvc.UI;

@Html.Telerik().DropDownList().Name("SpecificationAttributeOptionName")


Models/Catalog/ProductSpecificationAttributeModel.cs


        ...
        [NopResourceDisplayName("Admin.Catalog.Products.SpecificationAttributes.Fields.SpecificationAttributeOption")]
        [AllowHtml]
        [UIHint("ProductSpecificationAttributeOptions")]
        public string SpecificationAttributeOptionName { get; set; }

        ...


Controllers/ProductController.cs (within Product specification attributes region)


        public ActionResult GetSpecificationAttributeOptionNames(int selectedId)
        {
            var specificationAttributeOptions = _specificationAttributeService.GetSpecificationAttributeOptionsList(selectedId);
            var returnData = new SelectList(specificationAttributeOptions, "Id", "Name");
            returnData.Where(x => x.Value == selectedId.ToString()).FirstOrDefault().Selected = true;
            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.