Jump to content


Photo

UnimDBGrid DisplayFormat for numeric columns


  • Please log in to reply
4 replies to this topic

#1 DayTripper

DayTripper

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 11 December 2017 - 12:02 PM

Hi all,

 

Does anyone know is there a way to format numeric values on mobile DBGrid.

Normal uniDBGrid can do it in renderer function, what about mobile DBGrid?

 

Than you.

 

Best regards,

Simon


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4991 posts

Posted 11 December 2017 - 12:42 PM

Hi,

 

Which edition and build are you using ?!

 

Best regards,


  • 0

#3 DayTripper

DayTripper

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 11 December 2017 - 01:06 PM

Hi,

 

uniGUI Complete Trial Edition 1.0.0 Build 1421

 

Best regards,

Simon


  • 0

#4 pedrisco

pedrisco

    Member

  • Members
  • PipPip
  • 42 posts

Posted 22 February 2018 - 10:02 PM

Hi

I've found the same issue...

 

The quick way is write  the onGetText event for every field.

 

procedure TForm1.numberFieldGetText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
    text := formatFloat( TNumericField( sender ).DisplayFormat , sender.value );
end;

 

 

But if you have uniDBUtils.pas and you feel brave, you can touch the "numbers" section in the FieldValueToJS function:

    ...

    ftCurrency:
      begin
        if f.InheritsFrom( TNumericField ) and (TNumericField( f ).DisplayFormat<>'') then
            try
                result := '"'+formatFloat( TNumericField( f ).DisplayFormat , f.value )+'"';
            except
                Result := F.Value;
                // important: here we must use Delphi's {FormatSettings}.DecimalSeparator, becuase "F.Value" internally uses it to convert value to string.
                Result:=UniStringReplace(Result, {$ifdef COMPILER_15_UP}SysUtils.FormatSettings.{$endif}DecimalSeparator, '.');
            end
        else begin
            Result := F.Value;
            // important: here we must use Delphi's {FormatSettings}.DecimalSeparator, becuase "F.Value" internally uses it to convert value to string.
            Result:=UniStringReplace(Result, {$ifdef COMPILER_15_UP}SysUtils.FormatSettings.{$endif}DecimalSeparator, '.');
        end;
      end;
 


  • 0

#5 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4991 posts

Posted 23 February 2018 - 12:39 PM

Hello,

 

But if you have uniDBUtils.pas and you feel brave, you can touch the "numbers" section in the FieldValueToJS function:

    ...

    ftCurrency:
      begin
        if f.InheritsFrom( TNumericField ) and (TNumericField( f ).DisplayFormat<>'') then
            try
                result := '"'+formatFloat( TNumericField( f ).DisplayFormat , f.value )+'"';
            except
                Result := F.Value;
                // important: here we must use Delphi's {FormatSettings}.DecimalSeparator, becuase "F.Value" internally uses it to convert value to string.
                Result:=UniStringReplace(Result, {$ifdef COMPILER_15_UP}SysUtils.FormatSettings.{$endif}DecimalSeparator, '.');
            end
        else begin
            Result := F.Value;
            // important: here we must use Delphi's {FormatSettings}.DecimalSeparator, becuase "F.Value" internally uses it to convert value to string.
            Result:=UniStringReplace(Result, {$ifdef COMPILER_15_UP}SysUtils.FormatSettings.{$endif}DecimalSeparator, '.');
        end;
      end;
 

 

Which editon are you using ?!


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users