Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Auto-select constraint
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Auto-select constraint

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: Auto-select constraint
    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/
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2009 at 9:48am
Where do you get the pointer to the constraints?
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2009 at 6:01pm
AddConstraint return CXTPReportRecordItemConstraint*
or use CXTPReportRecordItemConstraint* pConstraint = GetEditOptions(NULL)->FindConstraint( specific Value );
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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(...)
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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,...)
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.