/// <summary> /// Fills the checkboxlist. /// </summary> /// <param name="options">The options.</param> /// <param name="chbl">The CheckBoxList to fill.</param> /// <param name="categoryId">Id of the option category which options belong to.</param> private void FillCheckboxlist(Dictionary <int, string> options, CMSCheckBoxList chbl, int categoryId) { // Fill checkboxlist with checkboxes foreach (KeyValuePair <int, string> pair in options) { string optName = pair.Value; optName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(optName)); ListItem chckbox = new ListItem(optName, "true"); chckbox.Selected = true; chbl.Items.Add(chckbox); // Map option(SKU) id to created checkbox int optId = pair.Key; optionToCheckBoxMap.Add(optId, chckbox); optionToCategoryMap.Add(optId, categoryId); } }
/// <summary> /// Generates the checkboxes. /// </summary> /// <param name="skuIdOfProductWithCategories">The SKU id of product with categories.</param> private void GenerateCheckboxes(int skuIdOfProductWithCategories) { optionToCheckBoxMap.Clear(); optionToCategoryMap.Clear(); Dictionary<int, string> categoriesWithName = GetCategoriesWithNames(skuIdOfProductWithCategories); foreach (KeyValuePair<int, string> pair in categoriesWithName) { int categoryId = pair.Key; string categoryName = pair.Value; // Ignore excluded categories if (ExcludedCategories.Contains(categoryId)) { continue; } Dictionary<int, string> optionsWithNames = GetOptionsWithNames(skuIdOfProductWithCategories, categoryId); if (optionsWithNames == null || optionsWithNames.Count == 0) { continue; } var row = new Panel { CssClass = "form-group" }; pnlFilterOptions.Controls.Add(row); // Label text set to CategoryDisplayName var lblCategoryDisplayName = new Label { Text = String.Format("{0}:", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(categoryName))), CssClass = "control-label" }; var chbl = new CMSCheckBoxList { RepeatDirection = RepeatDirection.Horizontal }; var cellLabel = new Panel { CssClass = "filter-form-label-cell" }; var cellCheckBoxList = new Panel { CssClass = "filter-form-value-cell-wide" }; cellLabel.Controls.Add(lblCategoryDisplayName); cellCheckBoxList.Controls.Add(chbl); row.Controls.Add(cellLabel); row.Controls.Add(cellCheckBoxList); // Category to table row mapping categoryToPanelMap.Add(categoryId, row); // Fill new checkboxlist with options from category FillCheckboxlist(optionsWithNames, chbl, categoryId); } }
/// <summary> /// Generates the checkboxes. /// </summary> /// <param name="skuIdOfProductWithCategories">The SKU id of product with categories.</param> private void GenerateCheckboxes(int skuIdOfProductWithCategories) { optionToCheckBoxMap.Clear(); optionToCategoryMap.Clear(); Dictionary <int, string> categoriesWithName = GetCategoriesWithNames(skuIdOfProductWithCategories); foreach (KeyValuePair <int, string> pair in categoriesWithName) { int categoryId = pair.Key; string categoryName = pair.Value; // Ignore excluded categories if (ExcludedCategories.Contains(categoryId)) { continue; } Dictionary <int, string> optionsWithNames = GetOptionsWithNames(skuIdOfProductWithCategories, categoryId); if (optionsWithNames == null || optionsWithNames.Count == 0) { continue; } var row = new Panel { CssClass = "form-group" }; pnlFilterOptions.Controls.Add(row); // Label text set to CategoryDisplayName var lblCategoryDisplayName = new Label { Text = String.Format("{0}:", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(categoryName))), CssClass = "control-label" }; var chbl = new CMSCheckBoxList { RepeatDirection = RepeatDirection.Horizontal }; var cellLabel = new Panel { CssClass = "filter-form-label-cell" }; var cellCheckBoxList = new Panel { CssClass = "filter-form-value-cell-wide" }; cellLabel.Controls.Add(lblCategoryDisplayName); cellCheckBoxList.Controls.Add(chbl); row.Controls.Add(cellLabel); row.Controls.Add(cellCheckBoxList); // Category to table row mapping categoryToPanelMap.Add(categoryId, row); // Fill new checkboxlist with options from category FillCheckboxlist(optionsWithNames, chbl, categoryId); } }
/// <summary> /// Fills the checkboxlist. /// </summary> /// <param name="options">The options.</param> /// <param name="chbl">The CheckBoxList to fill.</param> /// <param name="categoryId">Id of the option category which options belong to.</param> private void FillCheckboxlist(Dictionary<int, string> options, CMSCheckBoxList chbl, int categoryId) { // Fill checkboxlist with checkboxes foreach (KeyValuePair<int, string> pair in options) { string optName = pair.Value; optName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(optName)); ListItem chckbox = new ListItem(optName, "true"); chckbox.Selected = true; chbl.Items.Add(chckbox); // Map option(SKU) id to created checkbox int optId = pair.Key; optionToCheckBoxMap.Add(optId, chckbox); optionToCategoryMap.Add(optId, categoryId); } }