Skip to content

Commit

Permalink
#20 - fixed an issue with dictionary key collisions while adding vali…
Browse files Browse the repository at this point in the history
…d values for a parameter.
  • Loading branch information
alanjuden committed Mar 18, 2017
1 parent 7b20393 commit e652493
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AlanJuden.MvcReportViewer.NetCore/CoreHtmlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static HtmlString RenderReportViewer(this IHtmlHelper helper, ReportViewe
sb.AppendLine($" <select id='{reportParameter.Name}' name='{reportParameter.Name}' class='form-control' {(reportParameter.MultiValue == true ? "multiple='multiple'" : "")}>");
foreach (var value in reportParameter.ValidValues)
{
sb.AppendLine($" <option value='{value.Value}' {(reportParameter.SelectedValues.Contains(value.Value) ? "selected='selected'" : "")}>{value.Key}</option>");
sb.AppendLine($" <option value='{value.Value}' {(reportParameter.SelectedValues.Contains(value.Value) ? "selected='selected'" : "")}>{value.Label}</option>");
}
sb.AppendLine($" </select>");
}
Expand Down
2 changes: 1 addition & 1 deletion AlanJuden.MvcReportViewer.NetCore/ReportExportResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal void SetParameters(ReportService.ReportParameter[] definedReportParamet
{
foreach (var validValue in definedReportParameter.ValidValues)
{
reportParameter.ValidValues.Add(validValue.Label, validValue.Value);
reportParameter.ValidValues.Add(new ValidValue(validValue.Label, validValue.Value));
}
}

Expand Down
21 changes: 19 additions & 2 deletions AlanJuden.MvcReportViewer.NetCore/ReportParameterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,33 @@ public class ReportParameterInfo
public string Name { get; set; }
public string Prompt { get; set; }
public bool MultiValue { get; set; }
public Dictionary<string, string> ValidValues { get; set; }
public List<ValidValue> ValidValues { get; set; }
public List<string> SelectedValues { get; set; }
public ReportService.ParameterTypeEnum Type { get; set; }
public bool PromptUser { get; set; }
public bool AllowBlank { get; internal set; }

public ReportParameterInfo()
{
this.ValidValues = new Dictionary<string, string>();
this.ValidValues = new List<ValidValue>();
this.SelectedValues = new List<string>();
}
}

public class ValidValue
{
public string Label { get; set; }
public string Value { get; set; }

public ValidValue()
{

}

public ValidValue(string label, string value)
{
this.Label = label;
this.Value = value;
}
}
}
2 changes: 1 addition & 1 deletion AlanJuden.MvcReportViewer/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static MvcHtmlString RenderReportViewer(this HtmlHelper helper, ReportVie
sb.AppendLine($" <select id='{reportParameter.Name}' name='{reportParameter.Name}' class='form-control' {(reportParameter.MultiValue == true ? "multiple='multiple'" : "")}>");
foreach (var value in reportParameter.ValidValues)
{
sb.AppendLine($" <option value='{value.Value}' {(reportParameter.SelectedValues.Contains(value.Value) ? "selected='selected'" : "")}>{value.Key}</option>");
sb.AppendLine($" <option value='{value.Value}' {(reportParameter.SelectedValues.Contains(value.Value) ? "selected='selected'" : "")}>{value.Label}</option>");
}
sb.AppendLine($" </select>");
}
Expand Down
2 changes: 1 addition & 1 deletion AlanJuden.MvcReportViewer/ReportExportResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal void SetParameters(ReportService.ReportParameter[] definedReportParamet
{
foreach (var validValue in definedReportParameter.ValidValues)
{
reportParameter.ValidValues.Add(validValue.Label, validValue.Value);
reportParameter.ValidValues.Add(new ValidValue(validValue.Label, validValue.Value));
}
}

Expand Down
21 changes: 19 additions & 2 deletions AlanJuden.MvcReportViewer/ReportParameterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,33 @@ public class ReportParameterInfo
public string Name { get; set; }
public string Prompt { get; set; }
public bool MultiValue { get; set; }
public Dictionary<string, string> ValidValues { get; set; }
public List<ValidValue> ValidValues { get; set; }
public List<string> SelectedValues { get; set; }
public ReportService.ParameterTypeEnum Type { get; set; }
public bool PromptUser { get; set; }
public bool AllowBlank { get; internal set; }

public ReportParameterInfo()
{
this.ValidValues = new Dictionary<string, string>();
this.ValidValues = new List<ValidValue>();
this.SelectedValues = new List<string>();
}
}

public class ValidValue
{
public string Label { get; set; }
public string Value { get; set; }

public ValidValue()
{

}

public ValidValue(string label, string value)
{
this.Label = label;
this.Value = value;
}
}
}

0 comments on commit e652493

Please sign in to comment.