Print Page | Close Window

[HOWTO] Edit in header rows in virtual mode

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=23479
Printed Date: 19 April 2024 at 3:32am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [HOWTO] Edit in header rows in virtual mode
Posted By: mgampi
Subject: [HOWTO] Edit in header rows in virtual mode
Date 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



Replies:
Posted By: olebed
Date 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


Posted By: mgampi
Date 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


Posted By: mgampi
Date 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


Posted By: mgampi
Date 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


Posted By: olebed
Date 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


Posted By: mgampi
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net