0

The below one is the sample component on SellableItem entity. I want to store the list of items in "Scaling Componet" section.

public class ScalingComponents : Component { public decimal Rate { get; set; } = 0.00M; public decimal Qty { get; set; } = 0.00M; public string RecordNumber { get; set; } = string.Empty; public string RecordSeq { get; set; } = string.Empty; }

var sampleProduct= new SellableItem { Id = productEntityId, ProductId = product.ProductId, Name = product.ProductId, DisplayName = product.DisplayName, Components = new List {

              new ScalingComponents {
                  ChildComponents = new List<Component>
                    {
                        new ScalingComponents
                        {
                            Id = random.Next().ToString(),
                            Name = "scale1" ,
                           RecordNumber="1234",
                           RecordSeq ="1111",
                           Qty=1.20m,
                           Rate=2m
                        },
                         new ScalingComponents
                        {
                            Id = random.Next().ToString(),
                            Name = "scale2" ,
                           RecordNumber="5678",
                           RecordSeq ="2222",
                           Qty=4.20m,
                           Rate=4m
                        },

                    },

                    Name ="test"
              }
            }
        };

This code is not inserting 2 rows in "Scaling" section in Sellable item view. Am i missing anything here?

enter image description here

1

Here i did the below steps and i am able to add the list of data to Custom view

  1. Created "Table" type Parent EntityView
  2. Added the Properties ( column names ) to the parent view
  3. Created a child views with values
  4. Add all child views to Parent view.

Below is the sample code.

 var parentView = new EntityView
                {
                    Name = context.GetPolicy<ScaleViewsPolicy>().ItemScale,
                    DisplayName = "Scales",
                    EntityId = arg.EntityId,
                    ItemId = variationId,
                    UiHint = "Table"

                };


 var childView = new EntityView
            {
                Name = "Summary",
                DisplayName = string.Empty,
                EntityId = entityView.EntityId,
                ItemId = "|" + component.RecordNumber,
            };

childView.Properties.Add(
       new ViewProperty
       {
           Name = nameof(ScalingsComponents.RecordNumber),
           RawValue = component.RecordNumber,
           IsReadOnly = isReadOnly,
           IsRequired = false,
           OriginalType = "Html",

       });

 parentView.ChildViews.Add(childView);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.