ToolbarInput.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using FastReport.Web;
  2. using System;
  3. namespace FastReport.Web.Toolbar
  4. {
  5. /// <summary>
  6. /// Input field for the toolbar
  7. /// </summary>
  8. public class ToolbarInput : ToolbarElement
  9. {
  10. /// <summary>
  11. /// Type of input, which is specified in the type tag
  12. /// </summary>
  13. public string InputType { get; set; }
  14. /// <summary>
  15. /// Styles that are specified in the style tag for input
  16. /// </summary>
  17. public string InputCustomStyle { get; set; }
  18. /// <summary>
  19. /// Standard value for input
  20. /// </summary>
  21. public string InputDefaultValue { get; set; }
  22. /// <summary>
  23. /// Action to be triggered when user changes input value
  24. ///
  25. /// Can be either ElementScript or ElementChangeAction
  26. /// </summary>
  27. public IChangeAction OnChangeAction { get; set; }
  28. internal override string Render(string template_FR)
  29. {
  30. if (!Enabled) return default;
  31. var action = OnChangeAction is ElementScript elementScript
  32. ? elementScript.Script
  33. : $"{template_FR}.customMethodInvoke('{ID}', this.value)";
  34. return
  35. $@"<div class=""fr-toolbar-item fr-toolbar-notbutton {template_FR}-toolbar-item {template_FR}-toolbar-notbutton {ElementClasses}"" style = ""{ElementCustomStyle}"">
  36. <input style=""{InputCustomStyle}"" type=""{InputType}"" value=""{InputDefaultValue}"" title=""{Title}"" onchange=""{action}"">
  37. </div>";
  38. }
  39. }
  40. }