![]() |
Auto-select constraint |
Post Reply ![]() |
Author | |
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() 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/
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1198 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
Where do you get the pointer to the constraints?
|
|
PokerMemento - http://www.pokermemento.com/
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
AddConstraint return CXTPReportRecordItemConstraint*
or use CXTPReportRecordItemConstraint* pConstraint = GetEditOptions(NULL)->FindConstraint( specific Value );
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1198 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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/
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
You can do it just after you add a column to report itself -
CXTPReportColumn* pColumnStatus = wndReport.AddColumn(...) if (pColumnStatus)
pColumnStatus->GetEditOptions()->AddConstraint(...) |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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/
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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,...)
|
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
Ok, then the answer is; I've missed something :P
Thanks for the clear description!
|
|
PokerMemento - http://www.pokermemento.com/
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |