DBAdvGrid does not check grid's FormatType - assumes ftVCL

Hi!
Could you please check that DBAdvGrid does not internally (GetFormattedCell function) check the grid's FormatType for its known columns, so it acts as if the grid had ftVCL.

Meanwhile, based on AdvGrid.pas, I changed this, but it will be lost in next update:

      case FormatType of
        ftVCL : Result := Format(fmt, [Floats[ACol, ARow]]);
        ftExcel :
          begin
            try
              {$IFDEF DELPHIXE_LVL}
              Result := XlsFormat(Floats[ACol, ARow], fmt);
              {$ENDIF}
            except
            end;
          end;
      end;

Thanks!

BTW, now I noticed that this function doesn't have the same integer type check that is done in AdvGrid.pas GetFormattedCell function.

I'm not sure what the reason of your question / remark is.
DBAdvGrid uses the Column's setting FormatFloat when it is defined.
What different behavior do you want and for what reason?

DBAdvGrid.pas GetFormattedCell source code does not check if the grid has FormatType = ftExcel. It doesn't have a case FormatType of clause. If I use formats like '#,##0' (assign it to the grid's column) and FormatType=ftExcel, it simply doesn't work. Outputs literally '#,##0' at the cell.

It fails when it's configured at grid's column level (TDBGridColumnItem.FloatFormat).

Ok, I understood the point now better and we'll implement an improvement for the next update.

Hi!

It did not work. I believe the fix is mentioned under VCL UI Pack version 13.1.5.0, which says:
image

It's definetly not fixed, and now even worse. If I put ftExcel, now the grid shows with lot's of zeroes, even in columns where datafield is a TStringField. Also the fixed column shows "0" in all rows.

Just open DBAdvGrid demo CDSMasterDetail, ant set the upper grid FormatType to ftExcel, set FloatFormat to anything, and you'll get:

Design time:
image

Runtime:
image

when it should be like (running with ftVCL):
image

Yes, you added a ftExcel check, but it is not inside a " if IsFloat then " block, so it applies this float format to everything. Please check.

Thanks.

Hi!
Will you fix it by the next release, so we don't need to edit this code after updating?
Thanks.

When FormatFloat is not an Excel format specifier, you should not set FormatType to ftExcel.

Regardless of this, we have applied an improvement to make it more robust against an incorrect setting. This improvement will be in the next update.

You mean we should not use ftExcel at grid level if not every cell would have a number to be formatted?
Because I didn't mean I was using "anything" as only wrong formats, but any valid excel format. The problem was that it was trying to apply the format to non float columns too.

I'm talking what format you use for the FormatFloat property. It is either a VCL formatter or an Excel style formatter and FormatType selects that.

Regardless, we changed it to more it more robust and next build will have this change.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.