Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [HOWTO] Edit in header rows in virtual mode
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[HOWTO] Edit in header rows in virtual mode

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

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: [HOWTO] Edit in header rows in virtual mode
    Posted: 07 November 2017 at 4:23am
Hi;

I try to edit header row items when I use a virtual report control in Toolkit 18.0.1.
As a starting point I use the CJ "Virtual List Sample".

I modified the code by adding those lines to the CVirtualListView::OnCreate function:

wndReport.GetHeaderRecords()->Add(new CVirtualRecord(pSet));
wndReport.ShowHeaderRows(TRUE);
wndReport.HeaderRowsAllowAccess(TRUE);
wndReport.HeaderRowsEnableSelection(TRUE);
wndReport.HeaderRowsAllowEdit(TRUE);


In body section the edit control appears, but not in the header section.

What's wrong?

TIA


Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 07 November 2017 at 2:45pm
Hello Martin,

I have found what is the reason. Problem was in method CXTPReportControl::EditItem().
It resets pItemArgs->pRow but gets row always from body section. So fixed code is below:

void CXTPReportControl::EditItem(XTP_REPORTRECORDITEM_ARGS *pItemArgs)
{
    CXTPReportRecordItem *pItem = pItemArgs ? pItemArgs->pItem : NULL;

    if (NULL == m_pActiveItem && NULL == pItem)
    {
        // Nothing do to
        return;
    }

    if (m_pActiveItem != NULL)
    {
        m_pActiveItem->OnCancelEdit(this, TRUE);
        m_pActiveItem = NULL;

        if (!m_bFocusSubItems)
            SetFocusedColumn(NULL);
    }
    CMDTARGET_RELEASE(m_ptrVirtualEditingRow);

    if (pItem && pItemArgs && pItemArgs->pRow)
    {
        if (!HasFocus())
            SetFocus();

        if (!IsVirtualMode())
        {
            AdjustScrollBars();
            RedrawControl();
            UpdateWindow();
        }

        if (IsVirtualMode())
        {
            int nRowIndex = pItemArgs->pRow->GetIndex();
            CXTPReportSection* pSection = pItemArgs->pRow->GetSection();
            ASSERT(pSection != NULL);

            //EnsureVisible(pItemArgs->pRow);

            RedrawControl();
            UpdateWindow();
            pItemArgs->pRow = NULL; // RedrawControl delete and re-create new screen rows

            BOOL bMapped = FALSE;

            if (pSection)
            {
                CXTPReportScreenRows *pScreenRows = pSection->GetRows()->GetScreenRows();
                for (int i = 0; i <pScreenRows->GetSize(); i++)
                {
                    CXTPReportRow* pRow = pScreenRows->GetAt(i);
                    if (pRow->GetIndex() == nRowIndex)
                    {
                        pItemArgs->pRow = pRow;
                        bMapped = TRUE;

                        ASSERT(m_ptrVirtualEditingRow == NULL);

                        m_ptrVirtualEditingRow = pRow;
                        CMDTARGET_ADDREF(m_ptrVirtualEditingRow);
                        break;
                    }
                }
            }
            ASSERT(bMapped);
            if (!bMapped)
                return;
        }
        else if (GetFocusedRow() != pItemArgs->pRow)
        {
            BOOL bControlKey = (::GetKeyState(VK_CONTROL) < 0) || m_bMultiSelectionMode;
            SetFocusedRow(pItemArgs->pRow, bControlKey);
            UpdateWindow();
        }
    ....

Also you should use separated CVirtualRecord  for header or footer sections  because callback method for updating  CVirtualRecord::UpdateRecordField()  don't recognize sections. It used only row and column positions to identify records. Also for separates data sets. However maybe this will useful for you as is.

Regards,
 Oleksandr Lebed
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 08 November 2017 at 3:34am
Hi;

I'll try it and come back soon.
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2017 at 3:22am
It works Clap, thanks...

When will this be officially released?
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2017 at 6:17am
Hi;

Now I have another problem:
I have no records in the body section.
I'm editing an item in the (only single) header row. That's ok, but when I click into the header item a second time, the text disappears. Moving the focus out of the item without typing, I see the initially entered text again.
If the control has records in the body section, the item and edit control behave as expected.
Strange!
You can reproduce it with the above mentioned sample.
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2017 at 8:49am
Hi,
Originally posted by mgampi mgampi wrote:

When will this be officially released?

We are testing next release now but without recent changes.

Originally posted by mgampi mgampi wrote:

but when I click into the header item a second time, the text disappears.
 
On updating ReportControl the text are taken from DB, so I can suppose that you just don't save changes in DB. See methods CVirtualRecord::UpdateRecordField and CVirtualRecord::GetItemMetrics  in sample VirtualList\VirtualListView.cpp   My changes in Header section available also after restarting sample.

Regards,
 Oleksandr Lebed
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 13 November 2017 at 7:39am
Strange, but after a full recompile of the Toolkit it works.

TIA
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
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.