private string RenderCheckBox(UsedProperty property) { if (property.ValuesList.Count == 0) { return(string.Empty); } var sb = new StringBuilder(); sb.Append("<div class=\"chb-list propList\"> "); foreach (var value in property.ValuesList) { sb.AppendFormat("<div> <input name=\"prop_{0}\" type=\"checkbox\" id=\"prop_{1}\" value=\"{1}\"{2}{3} /> <label for=\"prop_{1}\">{4}</label></div> ", property.PropertyId, value.PropertyValueId, AvaliblePropertyIDs != null && !AvaliblePropertyIDs.Contains(value.PropertyValueId) ? " disabled=\"disabled\"" : string.Empty, SelectedPropertyIDs != null && SelectedPropertyIDs.Contains(value.PropertyValueId) ? " checked=\"checked\" " : string.Empty, value.Value ); } sb.Append("</div>"); return(sb.ToString()); }
private string RenderSelectBox(UsedProperty property) { var sb = new StringBuilder(); sb.AppendFormat("<div class=\"filter-select\"> <select id=\"prop_{0}\" name=\"prop_{0}\"> ", property.PropertyId); sb.AppendFormat("<option value=\"0\">{0}</option> ", Resources.Resource.Client_Catalog_FilterProperty_Any); var selectedChanged = false; foreach (var value in property.ValuesList) { if (AvaliblePropertyIDs == null || (AvaliblePropertyIDs != null && AvaliblePropertyIDs.Contains(value.PropertyValueId))) { var selected = !selectedChanged && SelectedPropertyIDs != null && SelectedPropertyIDs.Contains(value.PropertyValueId); sb.AppendFormat("<option value=\"{0}\"{1}>{2}</option> ", value.PropertyValueId, selected ? " selected=\"1\"" : string.Empty, value.Value); if (selected) { selectedChanged = true; } } } sb.AppendLine("</select> </div>"); return(sb.ToString()); }
private string RenderPropertyValues(UsedProperty property) { switch (property.Type) { case (int)PropertyType.Checkbox: return(RenderCheckBox(property)); case (int)PropertyType.Selectbox: return(RenderSelectBox(property)); case (int)PropertyType.Range: return(RenderRange(property)); } return(string.Empty); }
private string RenderRange(UsedProperty property) { var sb = new StringBuilder(); var list = property.ValuesList.Select(v => v.Value.TryParseFloat()).Where(v => v != 0).ToList(); if (list.Count < 1) { return(string.Empty); } var min = list.Min(); var max = list.Max(); if (min == max && min == 0) { return(string.Empty); } var curmin = min; var curmax = max; if (SelectedRangePropertyIDs != null && SelectedRangePropertyIDs.ContainsKey(property.PropertyId)) { curmin = SelectedRangePropertyIDs[property.PropertyId].Key; curmax = SelectedRangePropertyIDs[property.PropertyId].Value; } sb.AppendFormat( "<div class=\"content-price\" id=\"filter-pricerange-{0}\"> " + "<div class=\"slider\" data-current-min=\"{1}\" data-current-max=\"{2}\"> " + "<input autocomplete=\"off\" type=\"text\" class=\"min\" value=\"{3}\"/> " + "<input autocomplete=\"off\" type=\"text\" class=\"max\" value=\"{4}\" /> " + "</div> " + "</div>", property.PropertyId, curmin.ToString().Replace(",", "."), curmax.ToString().Replace(",", "."), min.ToString().Replace(",", "."), max.ToString().Replace(",", ".")); return(sb.ToString()); }