Rating

TsgcHTMLComponent_Rating — renderize uma exibição ou entrada de avaliação por estrelas (símbolo) com um campo de formulário oculto opcional, em Delphi, C++ Builder e .NET.

TsgcHTMLComponent_Rating

Um componente de avaliação que emite uma linha de símbolos preenchidos e vazios dimensionados e coloridos a gosto, mais uma entrada oculta opcional carregando o valor. Defina o valor e o máximo e então leia a propriedade HTML.

Classe do componente

TsgcHTMLComponent_Rating

Renderiza

Avaliação por símbolo + entrada de formulário oculta

Linguagens

Delphi, C++ Builder, .NET

Crie, defina o valor, renderize

Defina Value e MaxValue, escolha uma cor e símbolos e então leia HTML — ou chame o helper estático Build para uma linha única.

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");

Principais propriedades & métodos

Os membros que você usa com mais frequência.

Valor

Value define quantos símbolos são preenchidos de MaxValue (padrão 5); ShowValue adiciona uma legenda value/max.

Modo

ReadOnly (padrão True) renderiza a avaliação como uma exibição estática; defina-o como False para uma entrada interativa.

Cor

Color define a cor do símbolo preenchido como uma string CSS; ColorStyle (TsgcHTMLColor, por exemplo hcWarning) escolhe uma cor Bootstrap quando Color está vazio.

Símbolos

FilledSymbol e EmptySymbol substituem os glifos (estrela padrão ★); Size define o tamanho da fonte.

Vinculação a formulário

Defina InputName para emitir um <input> oculto carregando o valor numérico para que a avaliação seja enviada junto com o formulário.

Helper estático & saída

Build(value, maxValue, color) retorna o markup em uma linha; HTML retorna a linha de símbolos mais a entrada oculta opcional.

Continue explorando

Todos os Componentes sgcHTMLExplore a matriz completa de recursos com mais de 60 componentes.
Baixar Versão de Avaliação GratuitaA avaliação de 30 dias inclui os projetos de demonstração 60.HTML.
PreçosLicenças Single, Team e Site com código-fonte completo.

Pronto para Começar?

Baixe a versão de avaliação gratuita e adicione avaliações por estrelas à sua aplicação web Delphi, C++ Builder ou .NET.