Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Update all cells in row when constraint is changed
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Update all cells in row when constraint is changed

 Post Reply Post Reply
Author
Message
venkateshr View Drop Down
Newbie
Newbie


Joined: 04 February 2013
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote venkateshr Quote  Post ReplyReply Direct Link To This Post Topic: Update all cells in row when constraint is changed
    Posted: 04 February 2013 at 4:47am
Hello All,

I am using XT version 15.
Each column has its own constraint list which drops down when clicked in the cell

Requirement :  when column 2 (Record_0) selection is made, It should automatically update that row from the respective constraint list of each combo


Example : If option "4" is selected in column 2 (Record_0) combo list, it should update that row like
"4" "44" "444" "4444" "44444" which are in the constraint list of column 3,4,5,6
-------------------------------
Sample Code : (Tried)

m_xtReport.ModifyStyle ( NULL, WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP );
m_xtReport.GetReportHeader ( )->AllowColumnRemove ( FALSE );
m_xtReport.GetReportHeader ( )->AllowColumnReorder ( FALSE );
m_xtReport.GetReportHeader ( )->AllowColumnSort ( FALSE );
m_xtReport.EnableScrollBar ( SB_HORZ, TRUE );   

//---Add Columns and Constratints---//
int nRecd = 0; nCol = 0;

//Adding Grid Field
CXTPReportColumn* pGridColumn = m_xtReport.AddColumn ( new CXTPReportColumn ( nCol, "Grid", 300) );
if( pGridColumn )
{
    pGridColumn->SetSortable(FALSE);
    pGridColumn->GetEditOptions ( )->m_bAllowEdit =FALSE;   
}

//Adding Record_0
csCol.Format("Record_%d",nRecd); nRecd++; nCol++;
CXTPReportColumn* pRcrd1_Column = m_xtReport.AddColumn ( new CXTPReportColumn ( nCol, csCol, 300) );
if( pRcrd1_Column )
{
    //Adding combo list
    pRcrd1_Column->GetEditOptions ( )->AddConstraint ( "1", 0 );
    pRcrd1_Column->GetEditOptions ( )->AddConstraint ( "2", 1 );
    pRcrd1_Column->GetEditOptions ( )->AddConstraint ( "3", 2 );
    pRcrd1_Column->GetEditOptions ( )->AddConstraint ( "4", 3 );
    pRcrd1_Column->GetEditOptions ( )->AddConstraint ( "5", 4 );

    pRcrd1_Column->GetEditOptions ( )->m_bConstraintEdit = FALSE;
    pRcrd1_Column->GetEditOptions ( )->m_bAllowEdit =FALSE;// TRUE;
    pRcrd1_Column->GetEditOptions ( )->m_bSelectTextOnEdit =FALSE;// TRUE;
    pRcrd1_Column->GetEditOptions ( )->m_nMaxLength = 240;
    pRcrd1_Column->GetEditOptions ( )->AddComboButton ( );       
}

//Adding Record_1 ....
//Adding Record_2 .... etc...

//---Add records to report control---//
m_xtReport.AddRecord ( new CPxRecord () );
--

class CPxRecord : public CXTPReportRecord
{
public:
 CPxRecord(void)
 {
    //Sample show to add first row alone
    AddItem( new CXTPReportRecordItemText("1"));
    AddItem( new CXTPReportRecordItemText("11"));
    AddItem( new CXTPReportRecordItemText("111"));
    AddItem( new CXTPReportRecordItemText("111"));
    AddItem( new CXTPReportRecordItemText("1111"));
    AddItem( new CXTPReportRecordItemText("11111"));   
 }
 virtual ~CPxRecord(void);
}

//---Handle XTP_NM_REPORT_VALUECHANGED and update the row---//

//ON_NOTIFY(XTP_NM_REPORT_VALUECHANGED, IDC_GRID, OnReportValueChanged)

void CXmlDlg::OnReportValueChanged(NMHDR * pNotifyStruct, LRESULT * result)
{
    XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
        ASSERT(pItemNotify != NULL);

    int row = pItemNotify->pRow->GetIndex();
    int col = pItemNotify->pColumn->GetIndex();   

    CString cs(""), csData("");       

    //Get caption selected from combo
    cs = pItemNotify->pItem->GetCaption( pItemNotify->pColumn );   

    //search in the constraint
    CXTPReportRecordItemConstraint* pcnst = pItemNotify->pColumn->GetEditOptions()->FindConstraint(cs);

    //get the caption index
    int nIndex = pcnst->GetIndex();
   
    CXTPReportColumns    *pAllColumns = NULL;   
    CXTPReportRecords    *pAllRecords = NULL;

    pAllColumns = m_xtReport.GetColumns ( );
    int nRecordCount = pAllColumns->GetCount();

    pAllRecords = m_xtReport.GetRecords ( );

    for(int nItr = 0; nItr < nRecordCount-1; nItr++)
    {
        CXTPReportRecordItem *pItem = NULL;
        CXTPReportColumn    *pFieldColumn = NULL;       
        CXTPReportRecordItemConstraint* pcnstEx = NULL;
        CXTPReportRecord    *pOneRecord = NULL;

        if( nItr != 0 )    //leave first column
        {
            pOneRecord = pAllRecords->GetAt(nItr);
            pFieldColumn = pAllColumns->GetAt(nItr);
            pItem = pOneRecord->GetItem ( pFieldColumn );

            //Note : Data in all the constratint are indexed
            pItem->SetItemData(nIndex);    //set the constraint index for each cell of that row
        }       
    }

    m_xtReport.Populate();
}

Thanks


Back to Top
venkateshr View Drop Down
Newbie
Newbie


Joined: 04 February 2013
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote venkateshr Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2013 at 10:13am
Hello,

Is any one out there ?

Code Jock Administrator ?
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.137 seconds.