Objective Grid: Transferring data between a grid and a document

Article ID: 484
Last updated: 05 Jan, 2012
Article ID: 484
Last updated: 05 Jan, 2012
Revision: 1
Views: 1884
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 05 Jan, 2012
by Meltreger B.
Problem

How can I transfer data between the grid and the document when I am using other views (e.g. a hierarchy chart) and need to update all views when a cell value has changed?


Cause




Action

You should override StoreStyleRowCol( ) and store the style's value in your document.

  BOOL CSampleView::StoreStyleRowCol(ROWCOL nRow, ROWCOL nCol, const CGXStyle* pStyle, GXModifyType mt, int nType)
{
    if (mt == gxRemove) // not supported
      return FALSE;
    // Note: Do not distinguish between gxApplyNew,
// gxCopy and gxOverride
if (nRow > 0 && nCol > 0 && nType == 0)
{
      GetDocument( )->StoreCellValue(nRow, nCol, style.GetValueRef( ));
    }

return CMyGridView::StoreStyleRowCol(nRow, nCol, pStyle, mt, nType);

  }

You should override GetStyleRowCol( ) to retrieve the style's value from you doc:

  BOOL CSampleView::GetStyleRowCol(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, GXModifyType mt, int nType)
{
    BOOL b = CMyGridView::GetStyleRowCol(nRow, nCol, style, mt, nType);

// Note: Do not distinct between gxApplyNew,
// gxCopy and gxOverride
if (nRow > 0 && nCol > 0 && nType == 0 && mt != gxRemove)
{

      style.SetValue(GetDocument( )->GetCellValue(nRow, nCol);
    }

return b;

  }

In your other view's OnUpdate( ) method, you should update the view when you get a CGXGridHint object, with hint-ID gxHintUpdateStyleRange:

  void CMyOtherView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
    if (pHint != NULL && pHint->IsKindOf(RUNTIME_CLASS(CGXGridHint)))
{
      CGXGridHint &info = *((CGXGridHint*) pHint);

switch (info.nId)
{
case gxHintUpdateStyleRange:
case gxRedraw:

        Invalidate( );
break;
      }
    }
  }

This article was:   Helpful | Not helpful
Report an issue
Article ID: 484
Last updated: 05 Jan, 2012
Revision: 1
Views: 1884
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 05 Jan, 2012 by Meltreger B.

Others in this category