Jump to content


Photo

NextGrid.Footer.FormatMask does not work correctly


  • Please log in to reply
28 replies to this topic

#1 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 12 February 2007 - 08:30 AM

Hello,

If we put format mask for nextgrid footer, it does not work as required. For example, I put ###,###,###,### in the Footer.FormatMask in the Column Salary of Demo1, if the column footer has no data, it show , , , and if the footer is right-aligned, it always show xxx,xxx,...

Regards,

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 13 February 2007 - 01:18 AM

Hello,

I suggest reading topic FormatMaskText function in Delphi help.

You will find formating rules there. Footer accept other characters than number and I have need to use this function

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 27 February 2007 - 09:23 AM

QUOTE (Boki (Berg) @ Feb 13 2007, 07:18 AM) <{POST_SNAPBACK}>
Hello,

I suggest reading topic FormatMaskText function in Delphi help.

You will find formating rules there. Footer accept other characters than number and I have need to use this function

regards


Thank you Borki,

In my case, the data in column and footer are numbers so I just remove format mask of the footer and it works well. Anyway I think you need to check why it show xxx,xxx,... if we put format mask for the footer and make the footer right-align.

Regards

#4 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 20 June 2007 - 06:26 AM

Hello Boki,

If I put format mask (#,##0) for the footer and make the footer right-align, the value is displayed quite far from right margin.

Regards

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 June 2007 - 07:58 AM

Hello Sayxanath,

Unfortunatelly, this is all to do with FormatMaskText function of Delphi, because I simply transfer string to FormatMaskText and TextOut values on screen. I have read that FormatMaskText have some bugs and limitations.

If you have any suggestion, this may help me. Maybe adding property MaskKind (mkAlpha, mkNumeric) will help. As you may see, FormatMask for TNxNumberColumn work very well with numbers.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 20 June 2007 - 03:23 PM

Hello Boki,

The mask works well but I think the problem is on displaying the formated value. You can check that if I do not put mask for footer, the masked value is displayed correctly (right align). But if I do it, the masked value is far away from the right margin.

#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 June 2007 - 03:27 PM

Hello Sayxanath,

I think that mask create this 2 blank spaces and then draw it. This made this extra space.

Try to:

1) add one TLabel
- set AutoSize to false,
- set Color to clYellow
- and Alignment to taRightJustify.
2) add one TButton and
- in OnClick add
CODE
Label1.Caption := FormatMaskText('#,##0', '1300');


You will see 2 blank spaces at the end.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#8 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 21 June 2007 - 06:20 AM

Hello Boki,

I think the root of the problem is you design the footer can contain characters so you use FormatMaskText to appy mask format and the behaviour of this function is different from what we expected, e.g the DisplayFormat of a persistent field. So we have to accept this.

In your example if we put the mask like this FormatMaskText('#,##0;0', '1300345'), there will be no redundent space but that is not we expect.

Regards

#9 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 21 June 2007 - 06:24 AM

QUOTE (Boki (Berg) @ Jun 20 2007, 01:58 PM) <{POST_SNAPBACK}>
Maybe adding property MaskKind (mkAlpha, mkNumeric) will help. As you may see, FormatMask for TNxNumberColumn work very well with numbers.

Hello Boki,

It is the best if you can do this.

Regards

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 June 2007 - 12:16 PM

Hello Sayxanath,

Can you please tell me how do you want to have number formated. I will try to find appropriate mask string for you.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 21 June 2007 - 01:21 PM

QUOTE (Boki (Berg) @ Jun 21 2007, 06:16 PM) <{POST_SNAPBACK}>
Hello Sayxanath,

Can you please tell me how do you want to have number formated. I will try to find appropriate mask string for you.

regards


Hello Boki,

I like it works same as DisplayFormat of a TBCDField (you can create a persistent field to see that property). As I said in the last post, for a numeric value, I don't put mask for it and it can get the mask of the column.

Regards

#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 June 2007 - 02:01 PM

Hello Sayxanath,

This format (FormatFloat function from Delphi) I am using for NxNumberColumn too, but this work when data type is only number. But in Footer.Caption and other characters may be stored sad.gif This is why I use FormatMaskText function there.

Maybe you can use FormatFloat directly, before writing into Footer.Caption?

I have think and maybe MaskKind property is not good idea sad.gif , but maybe I may add FormulaMask (string) because Formulas are allways numbers.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#13 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 22 June 2007 - 01:06 PM

Hello Boki,

I am sorry to say that I don't need it indeed. I just report you the strange behaviour of the result string in the footer if we put mask string for it. As I said serveral times before, the mask of the column also works for the footer so I have no idea if you drop the mask of the footer.

Regards

#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 June 2007 - 01:10 PM

Hello Sayxanath,

For number columns there is no problems thanks to FormatFloat function which work very fine. But, when strings need to be "masked", FormatFloat can't be used anymore sad.gif

This is why I need to use FormatMaskText then, and this function work different than FormatFloat sad.gif

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#15 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 21 November 2007 - 02:05 PM

Hello Boki,

I have to come back to this post since I have problem with Footer's Format Mask with the new version of NextGrid. In the version 4.0.1, the column's Format Mask also works for footer (we don't need to provide Footer's Format Mask). But from the version 4.1.5, this behavior has change. Now we don't have masked value in footer by any way.

I use Delphi 7.

#16 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 November 2007 - 03:24 PM

Hello Sayxanath,

I recommend using next code before you set Format.Caption property:

CODE
procedure TForm1.Button1Click(Sender: TObject);
var
  N: Double;
begin
  N := 5122198.13;
  NextGrid1.Columns[0].Footer.Caption := FormatFloat(TNxNumberColumn(NextGrid1.Columns[0]).FormatMask, N);
end;


I hope that this code will help you. Just change N variable to desired variable/value.

This code will set same FormatMask as for column.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#17 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 22 November 2007 - 05:19 AM

Thank you for replying quickly. Adding this code is quite simple for a single value but if the value in the footer is calculated by a formula, we have to replace NextGrid's formula by our own one. It will become very messy if we use NextGrid in many forms. I hope that you will fix this bug soon or at least restore its behavior same as version 4.0.1.

Kind regards

#18 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 November 2007 - 08:35 AM

Hello Sayxanath,

But, I didn't change this behaviour in last release. I am still using FormatMaskText procedure as before (as I mentioned on top of the topic).

Please note that Footer.Caption may contain letters and numbers, but FormatMask is used for NumberColumn only. This is why I needed to use different functions for Footer and for NumberColumn.

Maybe only solution is to have FormulaFormatMask property.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#19 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 22 November 2007 - 10:51 AM

Hello Boki,

You may not change it directly but other update can change it indirectly. You still remember that the multi-line caption header feature break Unicode typing in Delphi 7, don't you?

Let me say again my problem.

I have number column. The formula kind is fkSum. I put #,##0 as the column format mask. I leave footer format mask blank. The column alignment and footer alignment is taRightJustify.

When I compile it with NextGrid v4.0.1, the footer value is masked perfectly.

When I compile it with NextGrid v4.1.5 or 4.2.1, the footer value is not masked any more.

So the conclusion is something has changed.

I don't see any benefit of using mask for character data. People tend to use format mask for number data only. But if you want to keep it like this, you can allow user to choose FormatMaskText or FormatFloat to be applied. This property can be added for both column and footer. By this way, you don't need to care the data are number or not neither a formula is used or not.

Kind regards

#20 Vu Quang Thang

Vu Quang Thang
  • Members
  • 91 posts

Posted 22 November 2007 - 11:18 AM

Hello Boki,

When I read through this topic again, I found that you recommended to use MaskKind in the post # 5 but in the post # 9 you said it is not a good idea. I don't know why you said it is not good. From the end user's point, it is better than using Formula Mask (string). If you add Formula Mask, there will be two format masks for the footer and user can be confuse.

Kind regards,




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users