locked
Is it possible to condense duplicate data rows with little segregation in the new rows RRS feed

  • Question

  • User1326214869 posted

    I have a parent control and on clicking the drop down we expand the below rows where we get the below list from repeater.
    Now again the same kind of drop down implementation we want when we click on the child {where we load the same row twice , one for retial and the other for professional, every data remains the same except the price and stock for retail and professional; we show this drop down only when we have the variant as retail & professional.} 

    protected void rptVariants_ItemDataBound(object sender, RepeaterItemEventArgs e)
    		{
    			var item = e.Item;
    			var variant = (SpaFinder.SpaBooker.IProductVariant)item.DataItem;
    			var product = variant.Product;
    
    			var trVariant = (HtmlTableRow)item.FindControl("trVariant");
    			var tdLabel = (HtmlTableCell)item.FindControl("tdLabel");
    			var lblVariant = (Label)item.FindControl("lblVariant");
    			var lblPrice = (Label)item.FindControl("lblPrice");
    			var lblInventoryWarning = (Label)item.FindControl("lblInventoryWarning");
    			var aTopVariant = (HtmlAnchor)item.FindControl("aTopVariant");
    			var variantText = product.Name;
    			var thisRepeater = (Repeater)sender;
    			var parentRepeater = (RepeaterItem)thisRepeater.NamingContainer;
    			var parentRepeaterIndex = parentRepeater.ItemIndex;
    			var currentClass = parentRepeaterIndex % 2 == 0 ? "xTr" : "xAltTr";
    			const string hoverClass = "xHoverTr";
    			trVariant.Attributes["class"] = currentClass;
    			trVariant.Attributes["onMouseOver"] = "this.className=this.className.replace('" + currentClass + "', '" + hoverClass + "');";
    			trVariant.Attributes["onMouseOut"] = "this.className=this.className.replace('" + hoverClass + "', '" + currentClass + "');";
    
    			var productIndex = CurrentProductIndex;
    
    			//var isFirstVariant = IsBindingFirstVariant;
    			lblVariant.Visible = false;
    			aTopVariant.Visible = false;
    
    			if (variant is ProductVariant)
    			{
    				var pv = variant as ProductVariant;
    				lblPrice.Text = WebSiteStringFormatter.FormatCurrency(pv.TagPrice);
    				lblInventoryWarning.Text = string.Format("<span class='{0}'>", ((pv.IsUnlimited != true && pv.Inventory == 0) ? "warning" : string.Empty));
    				lblInventoryWarning.Text += pv.IsUnlimited == true ? I18N("Unlimited") : pv.Inventory.ToString();
    				lblInventoryWarning.Text += "</span>";
    			}
    			var multipleSiblings = UserContext.Current.IsBrandContext ? product.HasMultipleMasterVariants : product.HasMultipleVariants;
    			if (!multipleSiblings)
    			{
    				lblVariant.Visible = true;
    				lblVariant.Text = variantText;
    			}
    			else
    			{
    				lblVariant.Visible = true;
    				lblVariant.Text = variantText;
    				tdLabel.Attributes["class"] = "product";
    				trVariant.Attributes["class"] += " sub";
    				trVariant.Attributes["itemNum"] = productIndex.ToString();
    				trVariant.Attributes["style"] = "display: none;";
    			}
    
    			if (variant is ProductVariant)
    			{
    				bool hasInventory = (variant as ProductVariant).IsUnlimited == true || (((ProductVariant)variant).Inventory > 0);
    				if (!hasInventory)
    					trVariant.Attributes["class"] += " out-of-stock";
    			}	
    			SetColumnVisibility(item);
    			IsBindingFirstVariant = false;
    		}
    <asp:Repeater ID="rptVariants" runat="server" OnItemDataBound="rptVariants_ItemDataBound">
    <ItemTemplate>
    <tr id="trVariant" runat="server">
    <td id="tdCheckboxTb" runat="server">
    <asp:CheckBox ID="chkSelection" runat="server" />
    <asp:HiddenField ID="hdnVariantID" runat="server" Value='<%#Eval("ID") %>' />
    <asp:HiddenField ID="hdnVendorID" runat="server" Value='<%#Eval("VendorID") %>' />
    </td>
    <td id="tdLabel" runat="server">
    <asp:Label ID="lblVariant" runat="server" CssClass="product-name" />
    <a id="aTopVariant" class="items" runat="server" />
    <%# GetStringValue(Eval("isProfessional")) == "True" ? "<img src='../../Images/icon-professional.png'>":""%>
    <%--<a id="aThumbnail" class="icon item-preview imageThumbnailIco" target="_blank" runat="server"><%= I18N("preview") %></a>--%>
    </td>
    <td>
    <%# Eval("Volume") == null ? "" : ( Eval("Volume") + " " + Eval("UnitOfMeasure.Name") ) %>
    </td>
    <td>
    <%# Eval("Color")%>
    </td>
    <td>
    <%# Eval("SKU") %>
    </td>
    <td class="ctrl-category">
    <%# Eval("Product.Category.Name")%>
    </td>
    <td>
    <%# Eval("Product.SubCategory.Name")%>
    </td>
    <td>
    <%# Eval("Product.ProductBrand.Name") %>
    </td>
    <td>
    <asp:Label runat="server" ID="lblInventoryWarning"></asp:Label>
    <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%# IsOnOrder((int?)Eval("ID")) %>'>&nbsp;-&nbsp;<span class="italic"><asp:Literal ID="ltlOnOrder" runat="server" Text="<%$I18N: ON ORDER %>" /></span>
    </asp:PlaceHolder>
    </td>
    <td>
    <asp:Label runat="server" ID="lblPrice"></asp:Label>
    </td>
    <td id="tdRetailTb" runat="server" class="cAlign">
    <%# HtmlBuilder.GenBoolCheckMark((bool?)Eval("IsRetail"))%>
    </td>
    <td id="tdProfessionalTb" runat="server" class="cAlign">
    <%# HtmlBuilder.GenBoolCheckMark((bool?)Eval("IsProfessional"))%>
    </td>
    <td id="tdOnlineTb" runat="server" class="cAlign">
    <%# (bool?)Eval("AllowCustomersToBookOnline") == true ? I18NCommon("Yes") : I18NCommon("No")%>
    </td>
    <td class="product-brand-managed cAlign">
    <%# HtmlBuilder.GenBoolCheckMark((bool?)Eval("IsBrandManaged"))%>
    </td>
    <td id="tdActionTb" class="xActionIcons" runat="server">
    <%# UserContext.Current.AllowEditProducts ? HtmlBuilder.GenActionLink(I18NCommon("Edit"),
    string.Format("EditInventory.aspx?Operation={0}&ProductVariantID={1}&ProductID={2}", WebSiteConst.OPERATION_UPDATE, Eval("ID"), Eval("Product.ID")),
    null, null, "itemActionIcons editDetailsIcon")
    : ""%>
    <asp:PlaceHolder runat="server" ID="phrDelete">
    <asp:ImageButton ID="btnDelete" runat="server" CssClass="btnDelete" ImageUrl="/App/assets/images/skinImages7.4/closeX.png" ToolTip="<%$I18N: Delete %>"
    Visible='<%# UserContext.Current.AllowDeleteProducts %>'
    OnClick="btnDelete_Click" CommandArgument='<%# Eval("ID") %>' OnClientClick="return confirm('Are you sure you want to delete this product?');" />
    </asp:PlaceHolder>
    <asp:ImageButton ID="btnHistory" runat="server" ToolTip="<%$I18N: History %>" CssClass="history-icon" ImageUrl="/App/assets/images/common/history_icon.png" OnClick="btnHistory_Click" CommandArgument='<%# Eval("ID") %>' />
    <span class="translateLink">
    <%# !(bool)Eval("IsBrandManaged") && UserContext.Current.SpaID.HasValue && UserContext.Current.Spa.SupportMultiLanguages ?
    HtmlBuilder.GenActionLink(I18NCommon("Translate"),
    string.Format("TranslateProduct.aspx?ProductID={0}", Eval("Product.ID")))
    : ""%>
    </span>
    </td>
    </tr>
    </ItemTemplate>
    </asp:Repeater>

    Monday, July 27, 2020 6:34 AM

All replies

  • User-939850651 posted

    Hi vishalsha,

    According to your description, I tried to use the code you provided to reproduce your problem.

    I made a lot of changes to the code. In the end, I could only get a simple table. I think this is not the effect you expected.

    I have a parent control and on clicking the drop down we expand the below rows where we get the below list from repeater

    Do you mean that the content in the repeater will change with your drop-down selection? Or what else?

    Could you provide more details, mainly including:

    1.  Related sample code.
    2.  The question you have now.
    3.  The effect you expect.

    Best regards,

    Xudong Peng

    Tuesday, July 28, 2020 9:55 AM