Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to get the value from the specfied row and col in CExtReportGridWnd Collapse All
Subject Author Date
ven rag Sep 23, 2006 - 6:57 AM

Iam using CExtReportGridWnd ....When I double click I reterive the element from particular column and row...
I have already used CExtGridWnd


bool CDemoGrid::OnGbwAnalyzeCellMouseClickEvent(
    // the nChar parameter:
    // VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only
    UINT nChar,
    // the nRepCnt parameter:
    // 0 - button up, 1 - single click, 2 - double click,
    // 3 - post single click & begin editing
    UINT nRepCnt,
    // the nFlags parameter:
    // mouse event flags
    UINT nFlags,
    // the point paramerter
    // mouse pointer in client coordinates
    CPoint point )
{
    
    ASSERT_VALID( this );
        if( nRepCnt == 2 )
        {
            // if double click
            CExtGridHitTestInfo htInfo( point );
            HitTest( htInfo, false, true );
            if( ( ! htInfo.IsHoverEmpty() ) || htInfo.IsValidRect() )
            { // if some cell clicked } // if some cell clicked
                INT nColType = htInfo.GetInnerOuterTypeOfColumn();
                INT nRowType = htInfo.GetInnerOuterTypeOfRow();
                CExtGridCell * pCell =
                    GridCellGet( htInfo.m_nColNo,
                        htInfo.m_nRowNo, nColType,
                        nRowType );
                        
                if ( (pCell != NULL) && (!pCell->IsKindOf(RUNTIME_CLASS(CExtGridCellHeader))))
                { ASSERT_VALID( pCell );
            
                    CExtSafeString m_col1,m_col2;
                    
                    CExtGridCell * pCell1 =
                    GridCellGet( 1,
                        htInfo.m_nRowNo, nColType,
                        nRowType );

                    pCell1->TextGet(m_col1);

                    CExtGridCell * pCell2 =
                        GridCellGet( 2,
                        htInfo.m_nRowNo, nColType,
                        nRowType );

                    pCell2->TextGet(m_col2);

                    AfxMessageBox(m_col1);
AfxMessageBox(m_col2);

                 return true;
                }
                
            }
        }

        return CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent(nChar, nRepCnt, nFlags, point );
    
}

The Above code works fine in CExtGridWnd...

But When I use the Same code in CExtReportGridWnd I get error when I Drag the Header of a particular Column and place in the Form of a Tree
------>"When I separate the Column from the CExtReportGridWnd the Column no changes ..."Due to that I could not reterive the paricular element.
How to solve this problem....................

Pls send a sample code

Thank you




Suhai Gyorgy Sep 25, 2006 - 2:31 AM

In Support forum they asked a similar question already. Answer was in that thread:

Now the htInfo.m_nColNo and htInfo.m_nRowNo values specify valid row/column numbers in terms of CExtGridWnd class. We should convert them into the CExtReportGridColumn * and CExtReportGridItem * pointers which are used by the CExtReportGridWnd class:

	CExtReportGridColumn * pRGC = 
		STATIC_DOWNCAST(
			CExtReportGridColumn,
			pReportGridWnd->GridCellGetOuterAtTop( htInfo.m_nColNo, 0L )
		);
	HTREEITEM hTreeItem = pReportGridWnd->ItemGetByVisibleRowIndex( htInfo.m_nRowNo );
	CExtReportGridItem * pRGI = pReportGridWnd->ReportItemFromTreeItem( hTreeItem );
	ASSERT_VALID( pRGI );
	bool bReportItemIsGroupRow = ( pReportGridWnd->ItemGetChildCount( hTreeItem ) > 0 ) ? true : false;
	if( bReportItemIsGroupRow )
		return . . .; // WE THINK THIS IS NOT INTERESTING CASE
	CExtGridCell * pCell = pReportGridWnd->ReportItemGetCell( pRGC, pRGI );

ven rag Sep 27, 2006 - 5:49 AM

I have to explain the problem again....

For example if we have Four column in the ReportGrid as

s.no----------Name--------studid ------marks
row1 Test1 102 100
row2 Test2 103 90
row3 Test3 101 75

Suppose the above Table is in the Report Grid.... Whenever I doubleclick a "row2" I want to take the value of the Column Studid "103" and marks "90" from the Reportgrid cell....
I don’t want to take the value from a particular cell Where I double click....for example when I double click "Test3" Cell in the ReportGrid ,I want Studid "101" and mark "75" and I don’t want "test3" value...

This I have done in CExtGridWnd.......
for example I want to get the "Studid" for "row2" the below code can be used..

CExtGridCell * pCell1 =
GridCellGet( 2,
htInfo.m_nRowNo, nColType,
nRowType );

pCell1->TextGet(m_col1); //where htInfo.m_nRowNo will be equal to "row2"

But in the case of CExtReportGridWnd we have an option of changing the Column header(Drag drop option) and Also the Tree Structure can be arranged...ie for example I have columns in the CExtReportGridWnd as [s.no,name,studid,marks],suppose I change the order using by Drag and Drop as [name,s.no,marks,studid] or I make the ReportGrid in the From of a Tree...like below one...
+name
-sno
-marks
-Studid
In Both Case Drag and Drop and Tree Structure the Column no may Change ..I can’t Give as Below (note the value "2" ie theColumn number in the
GridCellGet Function)
CExtGridCell * pCell1 =
GridCellGet( 2,//this won’t work I will not get "Studid" because the Column number will changed ..as result of Drag and drop Option
htInfo.m_nRowNo, nColType,
nRowType );

Where ever I doubleclick I want the corresponding Column value ..The Row number will Change but not the Column number...
Note:......"I want the Drag and Drop option and also the Tree Structure......in the CExtReportGridWnd "
How to solve this Problem.....???????????????????????

Thank you
pCell1->TextGet(m_col1); //where htInfo.m_nRowNo will be equal to "row2"

Suhai Gyorgy Sep 27, 2006 - 6:59 AM

I understand now that you need all the values from the same CExtReportGridItem, and you really don’t care about which column they clicked.

So if you get the ReportGridItem as mentioned above, you can get for example StudId cell of it like this:

	CExtReportGridColumn * pRGC = ReportColumnGet( _T("Studid"), _T("Student Information"));
    ASSERT_VALID( pRGC );
	CExtGridCell * pCell = ReportItemGetCell( pRGC, pRGI );
	ASSERT_VALID( pCell ); //ASSERT_KINDOF( CExtGridCellNumber, pCell );
	pCell->TextGet(m_colStudId);
Surely you have to use the column- and category-name that you provided when registering the column, which is unfortunate, but this is the only way I know of right now.

ven rag Sep 28, 2006 - 8:45 AM

Thank very much for that.....

I have another question????

How to Set the Column width to zero in CExtReportGridWnd...So that I can hide the Column from the User...
This is done in the CExtGridWnd as below

for( int x = 0; x < nDemoColumnCount; x++ )
        {
            CExtGridCell * pHeaderCell =
                STATIC_DOWNCAST(CExtGridCell,
                m_wndGrid.GridCellGetOuterAtTop(
                    x,
                    0,
                    RUNTIME_CLASS(CExtGridCellHeader))
                    );
            ASSERT_VALID( pHeaderCell );
            CExtSafeString s;
            int nExtent=60;
            if (x==0)
            {s.Format( _T("%s")," Sno"); nExtent = 180;}
            if (x==1)
            {s.Format( _T("%s"),"studid"); nExtent = 0;}
            if (x==2)
            {s.Format( _T("%s"), " studname" ); nExtent = 180;}
                    
            pHeaderCell->TextSet( s );
            pHeaderCell->ExtentSet( nExtent );
        }
How can we give the Same thing in the CExtReportGridWnd..????After setting zero to that particular Column is there anyway that by resizing the
Header of the Column also the Column should not be visible to the user ,but we should be able to take the values from that Column..
for example if I make the Studid Column width=0 and by resizing the Studid Column ,it will be visible. How can I make it Hidden...??

Thank you once again...

Technical Support Sep 28, 2006 - 12:13 PM

The CExtReportGridWnd class supports invisible columns. If you have a pointer to the CExtReportGridColumn object which specifies the column in the report grid window, then you can invoke the CExtReportGridWnd::ReportColumnActivate() method by specifying the false value in the bActivate parameter. This will deactivate the column and it will be visible only in the field chooser window but not in the report grid window.

ven rag Sep 30, 2006 - 5:40 AM

CExtReportGridWnd::ReportColumnActivate() does not invisible the Column .......Atlest We should not have the option of
making the Column Width=Zero So that the Column will be invisisble to the User ....
How to make the Column Width=Zero CExtReportGridWnd.......???


Thank U.

Technical Support Oct 2, 2006 - 11:41 AM

The CExtReportGridWnd::ReportColumnActivate() method makes columns visible/invisible and we can review your project to find out what’s wrong when you are using this method. It is also possible to make column having zero widths both in CExtReportGridWnd and in any CExtReportGridWnd-derived windows by setting extent values of the header cell. The CExtReportGridColumn class is used both as the report column identifier and as the header cell. So, you can set extents of this column:

CExtReportGridColumn * pRGC = . . .
pRGC->ExtentSet( 0, -1 ); // minimal width
pRGC->ExtentSet( 0,  0 ); // current width
pRGC->ExtentSet( 0, -1 ); // maximal width
CExtReportGridWnd * pReportGrid = . . .
pReportGrid->OnSwUpdateScrollBars( true );
pReportGrid->OnSwRecalcLayout();
pReportGrid->OnSwDoRedraw();


Suhai Gyorgy Oct 2, 2006 - 2:34 AM

If you set the column width to zero, users can still see the column, when they do a resizing. Support’s solution is partly OK, I think you just forgot to set the method’s parameter to false: you have to call CExtReportGridWnd::ReportColumnActivate(_T("studid"), _T("Student information"), false);
The 3rd parameter has to be set to false to hide the column. The only problem with this is that the column will be still visible in the field chooser window. How to remove it from there as well would be an interesting question.

ven rag Oct 5, 2006 - 9:02 AM


Set Below property

"m_wndGrid.ReportColumnProportionalResizingSet(false);"

and also setting pRGC->ExtentSet(0) value zero the Column get Hidden.......Now if the User Resizes also ,the Column is Hidden...
I think now it is ok..........


Thank u...