- 4
I updated the TabSpecifications to allow grouping. In our website it's very useful.
File: views\product\_ProductSpecifications.cshtml
Before:
Color: NameofColor
Color: NameofColor
Color: NameofColor ....
After:
Color: NameofColor, NameofColor, NameofColor...
If I want to group for example color into a single line I changed these lines below.
@{
var groupedList = Model.GroupBy(u => u.SpecificationAttributeName).Select(grp => grp.ToList()).ToList();
int a = -1;
foreach (var i in groupedList)
{
a++;
var item = i.First();
<tr @(a % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
<td class="spec-name">
@item.SpecificationAttributeName
</td>
<td class="spec-value">
@if (String.IsNullOrEmpty(item.ColorSquaresRgb))
{
if (i.Count() > 1)
{
foreach (var attr in i)
{
<div style="margin-right: 10px;">@Html.Raw(attr.ValueRaw)</div>
}
}
else
{
@Html.Raw(item.ValueRaw)
}
}
else
{
foreach (var color in i)
{
<div class="color-squares">
<span class="color-container" title="@Html.Raw(color.ValueRaw)" style="float:left;margin-right: 10px;border: 1px solid #d5d5d5">
<span class="color" style="background-color: @(color.ColorSquaresRgb);"> </span>
</span>
</div>
}
}
</td>
</tr>
}
}
File: views\product\_ProductSpecifications.cshtml
Before:
Color: NameofColor
Color: NameofColor
Color: NameofColor ....
After:
Color: NameofColor, NameofColor, NameofColor...
If I want to group for example color into a single line I changed these lines below.
@{
var groupedList = Model.GroupBy(u => u.SpecificationAttributeName).Select(grp => grp.ToList()).ToList();
int a = -1;
foreach (var i in groupedList)
{
a++;
var item = i.First();
<tr @(a % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
<td class="spec-name">
@item.SpecificationAttributeName
</td>
<td class="spec-value">
@if (String.IsNullOrEmpty(item.ColorSquaresRgb))
{
if (i.Count() > 1)
{
foreach (var attr in i)
{
<div style="margin-right: 10px;">@Html.Raw(attr.ValueRaw)</div>
}
}
else
{
@Html.Raw(item.ValueRaw)
}
}
else
{
foreach (var color in i)
{
<div class="color-squares">
<span class="color-container" title="@Html.Raw(color.ValueRaw)" style="float:left;margin-right: 10px;border: 1px solid #d5d5d5">
<span class="color" style="background-color: @(color.ColorSquaresRgb);"> </span>
</span>
</div>
}
}
</td>
</tr>
}
}