Rating
TsgcHTMLComponent_Rating — 渲染星级(符号)评分显示或输入,带有可选的隐藏表单字段,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_Rating — 渲染星级(符号)评分显示或输入,带有可选的隐藏表单字段,适用于 Delphi、C++ Builder 和 .NET。
一个评分组件,发出一行可按喜好设置大小和颜色的填充和空白符号,外加一个携带数值的可选隐藏输入框。设置数值和最大值,然后读取 HTML 属性。
设置 Value 和 MaxValue,选择颜色和符号,然后读取 HTML — 或调用静态 Build 辅助方法实现一行代码。
uses
sgcHTML_Component_Rating;
var
oRating: TsgcHTMLComponent_Rating;
begin
oRating := TsgcHTMLComponent_Rating.Create(nil);
try
oRating.Value := 4;
oRating.MaxValue := 5;
oRating.Color := '#ffc107';
oRating.ShowValue := True;
oRating.InputName := 'score';
oRating.ReadOnly := False;
WebModule.Response := oRating.HTML; // stars + hidden input
finally
oRating.Free;
end;
end;
// Or the static one-liner (value, maxValue, color):
Result := TsgcHTMLComponent_Rating.Build(4, 5, '#ffc107');
// includes: sgcHTML_Component_Rating.hpp
TsgcHTMLComponent_Rating *oRating = new TsgcHTMLComponent_Rating(NULL);
try
{
oRating->Value = 4;
oRating->MaxValue = 5;
oRating->Color = "#ffc107";
oRating->ShowValue = true;
oRating->InputName = "score";
oRating->ReadOnly = false;
String html = oRating->HTML; // stars + hidden input
}
__finally
{
delete oRating;
}
// Or the static one-liner:
String html = TsgcHTMLComponent_Rating::Build(4, 5, "#ffc107");
using esegece.sgcWebSockets;
var rating = new TsgcHTMLComponent_Rating();
rating.Value = 4;
rating.MaxValue = 5;
rating.Color = "#ffc107";
rating.ShowValue = true;
rating.InputName = "score";
rating.ReadOnly = false;
string html = rating.HTML; // stars + hidden input
// Or the static one-liner:
string html2 = TsgcHTMLComponent_Rating.Build(4, 5, "#ffc107");
您最常使用的成员。
Value 设置在 MaxValue(默认 5)中有多少个符号被填充;ShowValue 附加一个 value/max 标题。
ReadOnly(默认 True)将评分渲染为静态显示;将其设为 False 以获得交互式输入。
Color 将填充符号的颜色设置为 CSS 字符串;当 Color 为空时,ColorStyle(TsgcHTMLColor,如 hcWarning)选择一个 Bootstrap 颜色。
FilledSymbol 和 EmptySymbol 覆盖图标(默认为星形 ★);Size 设置字体大小。
设置 InputName 以发出携带数值的隐藏 <input>,使评分随表单一起回传。
Build(value, maxValue, color) 用一行代码返回标记;HTML 返回符号行以及可选的隐藏输入框。