yxzzjg Posted December 10, 2015 Posted December 10, 2015 dbgrid Columns proposed increase DisplayFormat property Quote
Administrators Farshad Mohajeri Posted December 10, 2015 Administrators Posted December 10, 2015 DisplayFormat can be adjusted from attached TField. Quote
yxzzjg Posted December 11, 2015 Author Posted December 11, 2015 DisplayFormat can be adjusted from attached TField. If not using ClientDataSet1, but the use of adoquery? adoquery Without this property Quote
Administrators Farshad Mohajeri Posted December 11, 2015 Administrators Posted December 11, 2015 In AdoQuery you can have fields too. It is same as any TDataSet. Quote
shawdown Posted July 10, 2018 Posted July 10, 2018 In VCL I used '000000' in the DisplayFormat to display integer codes in dbgrid always adding 0 to the left. Ex: When code was 20 then 000020 was displayed. In uniDBGrid it does not behave the same way. How can I make this integer formation in dbgrid? Quote
Sherzod Posted July 11, 2018 Posted July 11, 2018 Hi, In VCL I used '000000' in the DisplayFormat to display integer codes in dbgrid always adding 0 to the left. Ex: When code was 20 then 000020 was displayed. In uniDBGrid it does not behave the same way. How can I make this integer formation in dbgrid? You can open a ticket in support portal As a workaround you can try to use something like this I think: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { // 0 - your integer field index columns[0].renderer = function(v) { return (v.toString().padStart(6, '0')) } } Quote
gerardocrisci Posted July 11, 2018 Posted July 11, 2018 I think the problem can be solved http://forums.unigui.com/index.php?/topic/8468-tfloatfield-ongettext-no-display-in-grid/ Quote
gerardocrisci Posted August 23, 2018 Posted August 23, 2018 even if I insisted on having a simpler solution, today you have to write this code for the field's OnGetText method procedure TMainForm.DataSetMyFieldGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin Text:=FormatFloat('000000',Sender.AsFloat); end; But (if Farshad Mohajeri does not change his mind) his only works if you change the property in the column Column.ForceStringFormat =true Good job everyone Quote
Administrators Farshad Mohajeri Posted August 28, 2018 Administrators Posted August 28, 2018 Extjs formatter doesn't support adding them. In fact, putting extra zeros on front of a number has no meaning! It is best to align right numbers and add trailing zeros. Quote
gerardocrisci Posted August 28, 2018 Posted August 28, 2018 In fact, putting extra zeros on front of a number has no meaning! how do you not understand the usefulness? - in a vcl application it is possible to format a column. - in some databases the CAP is integer but is displayed with the forward zeros - in some cases you do not want to display zero ... but in its place a hyphen. - if you want to format the number of digits after the decimal point etc etc ... http://jira.fmsoft.net/servicedesk/customer/portal/4/FSD-568 I disagree with the visual result ... it can cause the original format to be lost to the field. I did a test ... always using the same code procedure TMainForm.ClientDataSet1LengthcmGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin Text:=FormatFloat('0.00',Sender.AsFloat); end; and the VCL and UniGui visualization is different... look at the image attached. I believe that UniGui is a great library and is used to bring your work on the web, keeping the operation more similar. Thanks and thanks again for your work. OnGetTextDiff.zip Quote
Administrators Farshad Mohajeri Posted August 28, 2018 Administrators Posted August 28, 2018 how do you not understand the usefulness? - in a vcl application it is possible to format a column. - in some databases the CAP is integer but is displayed with the forward zeros - in some cases you do not want to display zero ... but in its place a hyphen. - if you want to format the number of digits after the decimal point etc etc ... http://jira.fmsoft.net/servicedesk/customer/portal/4/FSD-568 I disagree with the visual result ... it can cause the original format to be lost to the field. I did a test ... always using the same code procedure TMainForm.ClientDataSet1LengthcmGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin Text:=FormatFloat('0.00',Sender.AsFloat); end; and the VCL and UniGui visualization is different... look at the image attached. I believe that UniGui is a great library and is used to bring your work on the web, keeping the operation more similar. Thanks and thanks again for your work. I think there is a misunderstanding here. I'm talking about leading zeros not zeros after the number. uniGUI supports trailing zeros. for example: 1,0000000 but not leading zeros: 000000001,0 Quote
gerardocrisci Posted August 28, 2018 Posted August 28, 2018 - in some databases the CAP is integer but is displayed with the forward zeros CAP - ZIP Code, codice postale es.Roma 00100 but in some databases the value is saved as an integer = 100 to get this, in case the field has a DisplayFormat or GetText I created this function function GetFieldUseDisplayFormat(Fld: TField): boolean; begin Result := false; if (Fld=nil) then exit; if ( Assigned(Fld.OnGetText) ) then Result := true else if Fld is TDateField then Result := (Fld as TDateField).DisplayFormat <> '' else if Fld is TTimeField then Result := (Fld as TTimeField).DisplayFormat <> '' else if Fld is TDateTimeField then Result := (Fld as TDateTimeField).DisplayFormat <> '' else if Fld is TCurrencyField then Result := (Fld as TCurrencyField).DisplayFormat <> '' else if Fld is TFloatField then Result := (Fld as TFloatField).DisplayFormat <> '' {$ifdef COMPILER_14_UP} else if Fld is TSingleField then Result := (Fld as TSingleField).DisplayFormat <> '' {$endif} {$ifdef COMPILER_11_UP} else if Fld is TExtendedField then Result := (Fld as TExtendedField).DisplayFormat <> '' {$endif} else if Fld is TBCDField then Result := (Fld as TBCDField).DisplayFormat <> '' else if Fld is TFMTBCDField then Result := (Fld as TFMTBCDField).DisplayFormat <> '' else if Fld is TNumericField then Result := (Fld as TNumericField).DisplayFormat <> '' end; I changed the line of the function GetFieldFormat(ACol: TUniBaseDBGridColumn; Fld: TField; var IsString: Boolean; var FType: string; DefaultFloatFormat: string =''): string; in the unit uniDBUtils Result := ''; FType := ''; IsString := True; if (ACol.ForceStringFormat) or GetFieldUseDisplayFormat(Fld) then // <-------- begin // it must be string end else if Fld is TDateField then I changed the line of the function TUniCustomDBGrid.GetCellData(const ColNo: Integer; var HasAttr: Boolean): TUniCellRecord; in the unit uniDBGrid else begin if GetFieldUseDisplayFormat(AField) then // <-------- begin if RawData then rValue := StrToJS(AField.DisplayText) else S := StrToJS(AField.DisplayText); end this variation created it every time I apply a version update. Quote
shawdown Posted September 5, 2018 Posted September 5, 2018 Extjs formatter doesn't support adding them. In fact, putting extra zeros on front of a number has no meaning! It is best to align right numbers and add trailing zeros. Strange that if you do the same on a TUniDBEdit it works perfectly. Quote
Pep Posted September 28, 2018 Posted September 28, 2018 Thank yoy very much for this code! I think It's the way like works in a regular VCL Grid On 8/28/2018 at 11:03 PM, gerardocrisci said: CAP - ZIP Code, codice postale es.Roma 00100 but in some databases the value is saved as an integer = 100 to get this, in case the field has a DisplayFormat or GetText I created this function function GetFieldUseDisplayFormat(Fld: TField): boolean; begin Result := false; if (Fld=nil) then exit; if ( Assigned(Fld.OnGetText) ) then Result := true else if Fld is TDateField then Result := (Fld as TDateField).DisplayFormat <> '' else if Fld is TTimeField then Result := (Fld as TTimeField).DisplayFormat <> '' else if Fld is TDateTimeField then Result := (Fld as TDateTimeField).DisplayFormat <> '' else if Fld is TCurrencyField then Result := (Fld as TCurrencyField).DisplayFormat <> '' else if Fld is TFloatField then Result := (Fld as TFloatField).DisplayFormat <> '' {$ifdef COMPILER_14_UP} else if Fld is TSingleField then Result := (Fld as TSingleField).DisplayFormat <> '' {$endif} {$ifdef COMPILER_11_UP} else if Fld is TExtendedField then Result := (Fld as TExtendedField).DisplayFormat <> '' {$endif} else if Fld is TBCDField then Result := (Fld as TBCDField).DisplayFormat <> '' else if Fld is TFMTBCDField then Result := (Fld as TFMTBCDField).DisplayFormat <> '' else if Fld is TNumericField then Result := (Fld as TNumericField).DisplayFormat <> '' end; I changed the line of the function GetFieldFormat(ACol: TUniBaseDBGridColumn; Fld: TField; var IsString: Boolean; var FType: string; DefaultFloatFormat: string =''): string; in the unit uniDBUtils Result := ''; FType := ''; IsString := True; if (ACol.ForceStringFormat) or GetFieldUseDisplayFormat(Fld) then // <-------- begin // it must be string end else if Fld is TDateField then I changed the line of the function TUniCustomDBGrid.GetCellData(const ColNo: Integer; var HasAttr: Boolean): TUniCellRecord; in the unit uniDBGrid else begin if GetFieldUseDisplayFormat(AField) then // <-------- begin if RawData then rValue := StrToJS(AField.DisplayText) else S := StrToJS(AField.DisplayText); end this variation created it every time I apply a version update. Quote
gerardocrisci Posted September 28, 2018 Posted September 28, 2018 Hi Pep, I hope my code will help you e I hope that Farshad Mohajeri will consider this solution. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.