Print Page | Close Window

Auto-select constraint

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=13145
Printed Date: 04 May 2024 at 10:13pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Auto-select constraint
Posted By: znakeeye
Subject: Auto-select constraint
Date Posted: 12 January 2009 at 8:10am

For a specific column I add a combo-button and a number of constraints. Example:

pColumnEnabled->GetEditOptions()->AddConstraint("Yes", TRUE);
pColumnEnabled->GetEditOptions()->AddConstraint("No", FALSE);
 
Now I create a custom CXTPReportRecord-class. For the 'Enabled' column I want to add an item like this:
 
AddItem(new CReportRecordItemEnabled(FALSE));
 
When I do that, I want the report control to automatically set the text "No". How?!
 
I managed to do this by overriding Populate() and manually updating the text, but this approach is very ugly.


-------------
PokerMemento - http://www.pokermemento.com/



Replies:
Posted By: mgampi
Date Posted: 12 January 2009 at 9:07am
Hi;

I did this by calling

        pConstraints->SetCurrent(xxx);
        SetValue(pConstraints->GetAt(xxx));

in the constructor of my custom item class.


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: znakeeye
Date Posted: 12 January 2009 at 9:48am
Where do you get the pointer to the constraints?

-------------
PokerMemento - http://www.pokermemento.com/


Posted By: mdoubson
Date Posted: 12 January 2009 at 6:01pm
AddConstraint return CXTPReportRecordItemConstraint*
or use CXTPReportRecordItemConstraint* pConstraint = GetEditOptions(NULL)->FindConstraint( specific Value );


Posted By: mgampi
Date Posted: 12 January 2009 at 6:40pm
Originally posted by znakeeye znakeeye wrote:

Where do you get the pointer to the constraints?

pConstraints=GetEditOptions()->GetConstraints();

HTH


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: znakeeye
Date Posted: 13 January 2009 at 2:41am
No, that won't work when the constraints are set per column! I need to access the columns, and then retrieve the constraints:
 
GetColumns()->GetColumn(3)->GetEditOptions()...
 
But it cannot be done inside the constructor of a report record :(


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: mdoubson
Date Posted: 13 January 2009 at 8:39am
You can do it just after you add a column to report itself -

CXTPReportColumn* pColumnStatus = wndReport.AddColumn(...)

if (pColumnStatus)
pColumnStatus->GetEditOptions()->AddConstraint(...)


Posted By: znakeeye
Date Posted: 13 January 2009 at 11:18am
Yes, but you're missing the point here. I believe there is a design flaw in XTP 12.1.1 (and earlier). Please, let me clarify what I mean.
 
Q: Record items do not auto-set their corresponding constraint value when CXTPReportControl is being populated. Is this by design?
 
I add a record:
m_wndReport.AddRecord(new CMyRecord(FALSE));
 
In the constructor of this record:
CMyRecord::CMyRecord(BOOL enabled)
{
    AddItem(new CMyRecordItem(enabled));
}
 
In the constructor of that item:
CMyRecordItem::CMyRecordItem(BOOL enabled)
: CXTPReportRecordItemText()
, m_enabled(enabled)
{
    // Here it should be possible to set a value that tells XTP to
    // look up m_enabled in the constraints when populating the control!
}
 
When I populate the report control I expect this item to automatically lookup its constraints and set the corresponding text! This does not happen, and I am forced to override Populate() and add ugly functions to get the desired behavior.
 
Hence, either I'm missing something here, or the design is flawed.


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: mdoubson
Date Posted: 13 January 2009 at 11:32am
No - it works logically. Let's make a sample base on ReportSample - TaskListView:

class CTaskRecord : public CXTPReportRecord

{

protected:

class CTaskItemType : public CXTPReportRecordItem

{

public:

CTaskItemType(BOOL bSharedTask)

{

m_taskType = bSharedTask;

}

void OnConstraintChanged(XTP_REPORTRECORDITEM_ARGS* /*pItemArgs*/, CXTPReportRecordItemConstraint* pConstraint)

{

if (pConstraint)

m_taskType = (BOOL) pConstraint->m_dwData;

}

CString GetCaption(CXTPReportColumn* pColumn)

{

CXTPReportRecordItemConstraint* pConstraint = pColumn->GetEditOptions()->FindConstraint(m_taskType);

ASSERT(pConstraint);

return pConstraint->m_strConstraint;

}

BOOL m_taskType;

};

.............................
 

CTaskRecord::CTaskRecord(

BOOL bSharedTask, TaskImportance taskImportance, BOOL bHasAttachment,

TaskStatus taskStatus, CString strSubject,

COleDateTime odtDueDate, int nComplete, CString strCategories)

{

AddItem(new CTaskItemType(bSharedTask));

AddItem(new CTaskItemImportance(taskImportance));

AddItem(new CTaskItemAttachment(bHasAttachment));

AddItem(new CTaskItemStatus(taskStatus));

AddItem(new CXTPReportRecordItemText(strSubject));

AddItem(new CTaskItemDueDate(odtDueDate));

AddItem(new CTaskItemComplete(nComplete));

AddItem(new CXTPReportRecordItemText(strCategories));

}

int CTaskListView::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CXTPReportView::OnCreate(lpCreateStruct) == -1)

return -1;

CXTPReportControl& wndReport = GetReportCtrl();

wndReport.GetImageManager()->SetIcons(IDB_BMREPORT, 0, 0, CSize(16, 16));

CXTPReportColumn* pColumnType = wndReport.AddColumn(new CXTPReportColumn(COLUMN_TYPE, _T("Type"), 48, TRUE, 0));

pColumnType->GetEditOptions()->AddConstraint(_T("Yes"), TRUE);

pColumnType->GetEditOptions()->AddConstraint(_T("No"), FALSE);

pColumnType->GetEditOptions()->m_bConstraintEdit = TRUE;

pColumnType->GetEditOptions()->m_bAllowEdit = TRUE;

pColumnType->GetEditOptions()->AddComboButton();

......................

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: About tooltips"), dtNone, 70, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusNotStarted, _T("Support Email: Docking Pane ToggleDocking"), dtNone, 0, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceHigh, TRUE, taskStatusNotStarted, _T("Feature Request: New Event for CommandBars"), dtNow, 0, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceHigh, TRUE, taskStatusCompleted, _T("Support Email: Help Taskpanel And ShortcutBar"), dtNow, 100, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, FALSE, taskStatusCompleted, _T("Support Email: RE: Docking Pane Window Overlapping Issues"), dtNow, 100, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, FALSE, taskStatusCompleted, _T("Support Email: CXTPPropertyGridItem"), dtNone, 100, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusCompleted, _T("Support Email: Toolbar Oddity"), dtNone, 100, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusCompleted, _T("Support Email: CXTPTabControl"), dtNone, 100, _T("")));

wndReport.AddRecord(new CTaskRecord(FALSE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: Menus go wrong if another form has topmost setting"), dtNone, 10, _T("")));

wndReport.AddRecord(new CTaskRecord(FALSE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: Update Xtreme Suite from 8.6 to 8.7"), dtNone, 0, _T("")));

wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceLow, TRUE, taskStatusInProgress, _T("Support Email: Bug in Tree-View on Label Edit"), dtNone, 0, _T("")));

....................
 
Now your first column automatically set Caption according of passed BOOL value (e.g. CTaskRecord(FALSE,...)


Posted By: znakeeye
Date Posted: 14 January 2009 at 2:57am
Ok, then the answer is; I've missed something :P
 
Thanks for the clear description!


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: mdoubson
Date Posted: 14 January 2009 at 3:03am
If you think that such answer is good for you without any details - you can get it from very begining. I consider that Forum is a school for everybody - not only for you.



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