Print Page | Close Window

[BUG] Metrics for Report Item doesn't show markup

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=13599
Printed Date: 28 April 2024 at 4:35pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [BUG] Metrics for Report Item doesn't show markup
Posted By: Aaron
Subject: [BUG] Metrics for Report Item doesn't show markup
Date Posted: 06 March 2009 at 10:35am
Hi,
 
Topic description says it all
 
I don't understand... In V12.1 this worked (and I didn't use it)  and now I want to use markup in ReportItems (yes just this once) and now it doesn't work. I thought this was an OK version but it isn't.
 
In V12.1 this works OK:
 

Metrics.Text = "<TextBlock>" & Item.Value & "<Bold Foreground='Red'>[Changed]</Bold></TextBlock>"

 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....



Replies:
Posted By: mdoubson
Date Posted: 06 March 2009 at 10:02pm
I checked our VB Report Sample and this code properly works -
        'Execute this code to apply predefined formatting.  To turn on automatic formatting, select it from the menu
        If (mnuAutomaticFormating.Checked) Then
           
            'Replace the backgroung color of every other row
            If ((Row.Index Mod 2 = 0) And (Row.GroupRow = False)) Then
                'This will dynamically change the BackColor of the ReportRecordItem, this value
                'is not saved in the Item.Backcolor property.  Once mnuAutomaticFormating.Checked is false,
                'the original backcolor is restored because this code is not executed
                Metrics.BackColor = RGB(245, 245, 245)
            End If
           
            'Change the text color of items that have the word "Undeliverable" in them
            If (Item.Index = COLUMN_SUBJECT) Then
                If (InStr(1, Item.Value, "Undeliverable", vbTextCompare)) Then
                    'This will dynamically change the text color of the ReportRecordItem, this value
                    'is not saved in the Item.ForeColor property.  Once mnuAutomaticFormating.Checked is false,
                    'the original text color is restored because this code is not executed
                    Metrics.ForeColor = vbRed
                End If
            End If
           
            'Apply fntStrike to the text of all items in a record that have a group caption of "Date: This Year"
            If (Row.Record(10).GroupCaption = "Date: This Year" And Item.Index <> -1) Then
                'This will dynamically change the font of the ReportRecordItem, this value
                'is not saved in the wndReportControl.PaintManager.TextFont property.  Once mnuAutomaticFormating.Checked is false,
                'the original font is restored because this code is not executed
                Metrics.Font.Strikethrough = True
            End If
           
        End If
This is not markup but this is custom draw support.
I don't remember markup sample except group row-related


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 07 March 2009 at 3:33am
Hi Mark,
 
I didn't say there was something wrong with metrics, ONLY MARKUP !!!
Just add the line of code in DrawBeforeRow event in version:
 
  1. V12.1.0 > Works OK
  2. V13.0.0 > grrrr.....


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 07 March 2009 at 12:37pm
You not right - it works, e.g.

CString cstrMarkupShortSample(_T("<StackPanel VerticalAlignment='Top' HorizontalAlignment='Center'><TextBlock><Bold>Subject:</Bold> </Italic> <Run Foreground='Red'>2009</Run> Released!</TextBlock></StackPanel>")); 

if (GetReportCtrl().GetMarkupContext()) {

GetReportCtrl().GetColumns()->GetAt(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);

GetReportCtrl().GetRecords()->GetAt(9)->GetItem(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);

GetReportCtrl().GetRecords()->GetAt(9)->GetItemPreview()->SetCaption(cstrMarkupLongSample);

GetReportCtrl().RedrawControl(); }

see snapshot https://forum.codejock.com/uploads/temp/20090307_123749_ScreenShot1.jpg - https://forum.codejock.com/uploads/temp/20090307_123749_ScreenShot1.jpg
 
 check item with text SuitPro 2009 - year colored by markup!
 
 
Port piece on VB :
 
Private Sub wndReportControl_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)
 
    Dim a As String
    a = "<StackPanel VerticalAlignment='Top' HorizontalAlignment='Center'><TextBlock><Bold>Subject:</Bold> <Italic>SuitePro</Italic> <Run Foreground='Red'>2009</Run> Released!</TextBlock></StackPanel>"
     If Item.Index = 1 Then 
             Item.Caption = a
             wndReportControl.PaintManager.RefreshMetrics
     End If
End Sub
 
see snapshot https://forum.codejock.com/uploads/temp/20090307_131129_VB_Markup.jpg - https://forum.codejock.com/uploads/temp/20090307_131129_VB_Markup.jpg
 
 


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 07 March 2009 at 2:28pm
Hi,
 
C'mon Mark, Metrics.Text should accept markup string and not the way you are doing this
 
Now here is test project and this is how it should work and not in a way you explained in previous reply.
 
https://forum.codejock.com/uploads/20090307_142913_TestMetrics.zip - uploads/20090307_142913_TestMetrics.zip
 
This is build with V12.1.0 OCX
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 07 March 2009 at 5:34pm
Sorry you always know how it SHOULD work and ignore when I show you HOW TO USE the feature. Wrong (obsolete) documention is not a reason of reporting bug but reason asking to fix the documentation

-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 08 March 2009 at 4:07am
Originally posted by mdoubson mdoubson wrote:

Sorry you always know how it SHOULD work and ignore when I show you HOW TO USE the feature. Wrong (obsolete) documention is not a reason of reporting bug but reason asking to fix the documentation
 
Hi Mark,
 
Did you pay attention Mark? The test project is NOT about showing you how it should work, only how it worked in previous version.
 
This has nothing to do with documentation. I (almost) never read that, only when having trouble with some things... Developers have built entire applications with V12.1 using Metrics.Text because it was implemented like that. They will be happy when upgrading to a newer version..... NOT !!! You can not change an implementation just for you own needs, NEVER !!!!.
 
And now you tell me I don't use it properly  I don't have to change GroupCaption of grouped row (BECAUSE IT WAS IMPLEMENTED LIKE THIS !!!!!) So Metrics.Text does support markup as implemented: 
 
  • Metrics.Text = "<TextBlock>" & rptGrouprow.GroupCaption & " " & "<Bold Foreground='Red'>" & "(" & rptGrouprow.Childs.Count & ")" & "</Bold></TextBlock>"
 
 
So this isn't a bug?
 
Thanks for nothing
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 08 March 2009 at 10:20pm
VirtualListEdit sample with markup-sample in

void CVirtualRecord::GetItemMetrics(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pItemMetrics){

......

case 5:

{

CString sMarkup;

sMarkup.Format(("<TextBlock><Bold Foreground='Red'>%s</Bold></TextBlock>"), m_pSet->m_Department);

pItemMetrics->strText = sMarkup;

break;

}

......
 
See snapshot : https://forum.codejock.com/uploads/temp/20090308_222137_ScreenShot2.jpg - https://forum.codejock.com/uploads/temp/20090308_222137_ScreenShot2.jpg
 
 
 


-------------
Mark Doubson, Ph.D.


Posted By: xiote
Date Posted: 12 March 2009 at 10:50pm
it dosn't work Metrics.Text markup in V13(ActiveX)
 


Posted By: mdoubson
Date Posted: 14 March 2009 at 12:45pm

void CXTPReportRecordItem::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics){

ASSERT(pDrawArgs->pItem == this);

//THIS CONDITION - IsVirtualMode() [Rev 7687 Oct 2008] PREVENTS MARKUP in Non-Virtual mode

//if (pDrawArgs->pControl->IsVirtualMode() && pDrawArgs->pControl->GetMarkupContext())

if (pDrawArgs->pControl->GetMarkupContext())

..................................................................
FIXED NOW = be in 13.1
this sample code properly run under recompiled OCX
Private Sub wndReportControl_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)
    Metrics.Text = "<TextBlock><Bold>Subject:</Bold> <Italic>SuitePro</Italic> <Run Foreground='Red'>2009</Run> Released!</TextBlock>"
End Sub


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 14 March 2009 at 2:02pm
Hi Mark,
 
I'm glad you saw the  
 
This is how it should work, if you want to do some magic stuff in BeforeDrawRow event, you shouldn't have to change caption of ReportItem, just leave original value as is and change Metrics.Text if you want to...
 
Thank you
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 01 May 2009 at 5:14pm
VB Sample run
    For i = 0 To 10
        Set XtremeColumn = ReportControl.Columns.Add(i, "Column " & i, i * 50 + 10, True)
            XtremeColumn.Caption = "<TextBlock>Click <Bold Foreground='Red'>(Me)</Bold></TextBlock>"
    Next i
   
    ReportControl.EnableMarkup = True


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 04 May 2009 at 10:42am
Hi Mark,
 
I know that, if you assign value to Column.Caption, it will work otherwise it doesn't. This has been always like this. (If you would add column and assign value it doesn't show markup). I have no problem with that 
 
But I'm glad you replied on this post. I had to try again because you said you fixed Metrics.Text (with Markup) in BeforeDrawRow event. A while ago I posted a bug regarding Markup when a column is dropped into Groupbox. The "button" in GroupBox shows Markup, but the "button" width is to small :(
 
 
To reproduce:
 
  • Size a column (with Markup) to: let's say 20 pixels (to be sure )
  • Drag column to GroupBox (Image 2)
  • Drag column without Markup (Image 3) There's no problem with this, it resizes OK
Output:
 
 
Thanks
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 04 May 2009 at 11:00am
Could not reproduce - repeat all your steps. If column wide is small - we can't see all markuped text in column but if you drag this column to group box - you see it totally with even extra empty pixels on right side

-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 04 May 2009 at 1:10pm
Hi Mark,
 
See post https://forum.codejock.com/forum_posts.asp?TID=12601 - https://forum.codejock.com/forum_posts.asp?TID=12601  for a test project. It was a sticky post but no one replied and after a while I let the post slide down the forum. But now you can actually do something about it
 
Thanks
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 04 May 2009 at 1:22pm
It was old-version embeded project. Please update it to the way I can load it with current version.

-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 04 May 2009 at 1:45pm
Hi,
 
I uploaded new version in that post.
 
Thanks
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 04 May 2009 at 2:18pm
Thanks. Now I see the problem with small column to drag. Will try to fix

-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 04 May 2009 at 4:09pm
So the problem is here:
this is a rectangle used to group item draw:

CRect rcItem(x, y, x + pColumn->GetCaptionWidth(pDC) + 50, y + nHeaderHeight - 3);

and function to GetCaptionWidth is here:

int CXTPReportColumn::GetCaptionWidth(CDC* pDC) {

if (m_pMarkupUIElement) {

CSize szText = XTPMarkupMeasureElement(m_pMarkupUIElement, m_rcColumn.Width(), INT_MAX);

return szText.cx;

}

return pDC->GetTextExtent(m_strName).cx;

}

so if XTPMarkupMeasureElement not properly calculated (and this is not a Report Control code but other component code) - we will have cutted text as we already see.

here CString m_strName; // Column name.



-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 04 May 2009 at 6:29pm
http://forum.codejock.com/uploads/20090504_182934_BetaReportContr.rar -
 
You test case working fine - get this update with fix for MarkUp done on Report Control level - check other cases please
 
  https://forum.codejock.com/uploads/DemoVersion/BetaReportControlMay05.rar - https://forum.codejock.com/uploads/DemoVersion/BetaReportControlMay05.rar


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 05 May 2009 at 2:16pm
Hi Mark,
 
It looks great  I don't see any problems
 
Thanks a lot


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 05 May 2009 at 2:48pm
http://forum.codejock.com/uploads/20090505_144853_RCRedraw.rar -
Good. Could you please play with this VB exe:
 
uploads/20090505_144853_RCRedraw.rar
 
Just test reaction on resizing
(btw - there is no modifications in ActiveX - just better initial settings in project)
 
Thanks for testing


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 06 May 2009 at 1:19am
Hi Mark,
 
I don't know what to look for but the only thing I see is that horizontal scrollbar becomes visible when last column isn't visible anymore (during sizing of form) And sometimes (I saw this about three times) when clicking on scrollbar, the scrollbar becomes invisible but I noticed that RC is 1 pixel wider when this happens...
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: mdoubson
Date Posted: 06 May 2009 at 11:09am
http://forum.codejock.com/uploads/20090506_110957_RCRedrawMod.rar -
Thanks - I just tried to find the best initial setup to make Jason model properly work.
Try this one please -
 
uploads/20090506_110957_RCRedrawMod.rar
 


-------------
Mark Doubson, Ph.D.


Posted By: Aaron
Date Posted: 06 May 2009 at 1:31pm
Hi Mark,
 
It looks OK to me, resizing goes well with both RC's and scrollbars are visible when needed.
 
Good job
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: jpbro
Date Posted: 06 May 2009 at 2:08pm
Hi Mark,

I've just tested this build as well, and everything looks perfect! Thanks a lot for all of your hard work on this issue.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: jpbro
Date Posted: 22 December 2010 at 11:06am
Sorry to drag up an old post, but I have a question about Metrics.Text and some behaviour that I find strange (and some behaviour that I require).

First, I want:

1) To be able to sort a report control column by a value that is different from what is displayed (easy).
2) The cell display should be automatically formatted with markup (easy)
3) The user to be able to edit a cell without any markup text appearing (apparently difficult, but maybe I am missing something).

I thought that in order to accomplish this, I would:

1) Set the Value property of a ReportRecordItem to the sortable value (for example, "2010-10-10T00:00:00Z")
2) Set the Caption property to the value that the user will edit (for example, "October 10, 2010"), 3) In the BeforeDrawRow event, set the Metrics.Text property to my markup formatted string (for example "<TextBlock><Span Backcolor='Yellow'>October</Span> 10, 2010</TextBlock>" (as long as the PaintManger.ForceDynamicMarkupForCell property was True).

This works in terms of sorting and displaying marked up values, but when the user tries to edit a cell, this is the result:



Why does the edit cell text appear with the markup tags if I only set the Metrics.Text property in the BeforeDrawRow event? My impression was that the Metrics object was for dynamic display purposes only, and the Caption property would be used for the edit cell text (or anywhere the Metrics.Text property wasn't set).

So my questions are:
1) Is this a bug?
2) If no to #1, is there a way to accomplish what I would like to do with the current ReportControl state?
3) If no to #2, can we have a way to accomplish this for the next version?

Thanks for any insights and help.


Also, here's a test project if required:

uploads/2676/RcEditMarkup.zip - uploads/2676/RcEditMarkup.zip




-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Aaron
Date Posted: 22 December 2010 at 12:14pm
Originally posted by jpbro jpbro wrote:

Sorry to drag up an old post, but I have a question about Metrics.Text and some behaviour that I find strange (and some behaviour that I require).

Why does the edit cell text appear with the markup tags if I only set the Metrics.Text property in the BeforeDrawRow event? My impression was that the Metrics object was for dynamic display purposes only, and the Caption property would be used for the edit cell text (or anywhere the Metrics.Text property wasn't set).

So my questions are:
1) Is this a bug?
2) If no to #1, is there a way to accomplish what I would like to do with the current ReportControl state?
3) If no to #2, can we have a way to accomplish this for the next version?

Thanks for any insights and help.


Also, here's a test project if required:

uploads/2676/RcEditMarkup.zip - uploads/2676/RcEditMarkup.zip


 
Hi Jason,
 
  1. O.... my....God....  Someone fu**ed up the ReportControl. You are right, Metrics object is designed for dynamic display purposes ONLY.
  2. What kind of sorting do you mean. RC supports sorting DATE & TIME values, numbers (int,long etc etc) and ordinary strings of course...
  3. Depending what you mean by 2. LOL
 
   
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: jpbro
Date Posted: 22 December 2010 at 6:30pm
Hi Aaron, thanks for the reply - so I'm not crazy then ;)

By #2, I meant that I generally want to accomplish the following:

3 "values" associated with a ReportControlItem:

1) A hidden value used for sorting purposes (i.e. the Value property)
2) A value used for editing and default display purposes (i.e. the Caption property)
3) A value used for dynamic formatting (display purposes only) that over-rides the Caption value when present (the Metrics.Text property).

The user should never see raw markup, so they should see the Caption property value when EditMode = True and see the Metrics.Text value (as rendered Markup if it's a markup string) when EditMode=False (or if Metrics.Text isn't set to anything in the BeforeDrawRow event, then just default the cell text to the Item.Caption value).

I used dates as just a simple example for demo, but what I really need a separate value for is a custom sort string that I create that allows me to sort alpha-numeric values smartly.

For example, if the user types this in 5 different cells:

A10
A3
A200
A1
A2

Normal sorting rules would display in this order:

A1
A10
A2
A200
A3

I have a routine which pads out internal numbers to something like this (again, example):

A00010
A00003
A00200
A00001
A00002

So that when you sort the list appears as:

A1
A2
A3
A10
A200

Of course, I don't want the user to see the padded out numbers, so I use the Value property for them. The user can type codes like A1, A2, etc... and they will now be sorted "correctly" but look just as they type them in the cell display and edit box. Lastly, different leading alpha characters (A, B, C, etc...) can have a different colour associated with them, so I want to use the Metrics.Text property to display the cell in a custom format.

I'm not sure why the edit window for a cell is defaulting to the Metrics.Text value - I've even tried changing the Metrics.Text property to Item.Caption in the RequestEdit and BeforeDrawRow events, but I haven't had any luck getting the edit window text to appear without markup tags...

I'll keep experimenting and also open a ticket.

Thanks for your help, Merry Christmas!


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: jpbro
Date Posted: 22 December 2010 at 6:57pm
Looks like you can use SendMessage on the InplaceEditHwnd with WM_SETTEXT to get the caption to appear without markup tags. I don't think we should have to do this though.

Here's a demo:

uploads/2676/RcEditMarkup2.zip - uploads/2676/RcEditMarkup2.zip

-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Oleg
Date Posted: 02 February 2011 at 7:39am
Thanks, this one is fixed.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jpbro
Date Posted: 02 February 2011 at 10:50am
Beautiful! Thanks Oleg.

-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net