Print Page | Close Window

HOWTO: Setting focus after reload from DB?

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=20449
Printed Date: 01 November 2025 at 8:10am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: HOWTO: Setting focus after reload from DB?
Posted By: mgampi
Subject: HOWTO: Setting focus after reload from DB?
Date Posted: 18 December 2012 at 5:09pm
Hi;

I'm populating the report control with data from a database table. These records are grouped by a single field.
Now I'm trying to implement a smart database reload function that restores the state of all rows in the control. This means the group expand state and the selected rows including the single focused row - as far as they still exist after executing the reload.
Due to the fact that CXTPReportControl::ResetContent() deletes all record and row collections, I'm unable to use these pointer after the reload. That's absolutely clear!
Selecting normal rows is no problem, but since group rows do not have any information inside (calling row->GetRecord() is NULL) I have no idea how to find the same group row AFTER the reload. So my question is: How can I mark a group row by a tag that i can use as a key to find the same group row in the reloaded control?
Did  I miss a callback when group rows are created or are there any functions around that help me in solving this issue?

TIA


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Replies:
Posted By: mgampi
Date Posted: 03 March 2013 at 2:03pm
Has really no one ever had the same to solve????


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: mgampi
Date Posted: 31 August 2016 at 11:05am
Still no solution for this?


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: cluster
Date Posted: 01 September 2016 at 6:35am
Hi Martin,

I am not sure if I understand you right, but maybe you have a look at the Report Sample:

void CReportSampleView::OnAutoGrouping()
{
    if (GetReportCtrl().GetColumns()->GetGroupsOrder()->GetCount() == 0)
    {
        CXTPReportColumn* pColFrom = GetReportCtrl().GetColumns()->Find(COLUMN_FROM);

        GetReportCtrl().GetColumns()->GetGroupsOrder()->Clear();

        GetReportCtrl().GetColumns()->GetGroupsOrder()->Add(pColFrom);
    }
    else
    {
        GetReportCtrl().GetColumns()->GetGroupsOrder()->Clear();
    }
    GetReportCtrl().Populate();
}



Posted By: mgampi
Date Posted: 01 September 2016 at 7:21am
Hi;

thanks for your reply, but it is definitely NOT what I am looking or.
I want to expand group rows and modify their caption after refetching from database, but only those that were marked as to change before the reload happens.
Problem is that group rows have no records attached to them to put some kind of additional identity into.

But nevertheless, thanks!

M.


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: jpbro
Date Posted: 01 September 2016 at 7:56am
Two admittedly ugly ideas I can think of:

1) Every group row must have at least 1 child row, correct? If so, you could store information about the GroupRow in the first child row.

2) Every group row has a unique caption - you can use that as a key for a separate data structure that holds the GroupRow information that links back to your database.

Hey, I didn't say they were pretty ;)


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: cluster
Date Posted: 01 September 2016 at 8:17am
Hi Martin,

you could store the state of the CXTPReportGroupRow in a map
CMap<CString*, CString*, int, int> map;

before you delete ( ResetContent() ) them. After populating and grouping you scan again the Rows and if you match a GroupRow ( IsGroupRow() ) you look in your map for the right caption name and reset the state.


Posted By: mgampi
Date Posted: 01 September 2016 at 11:26am
Hi;

To 1) This is true, but the first child row may change between reload calls.
To 2) The Caption is generated by data out of the database. This content may change too!

Therefore both suggestions need more investigations by myself.

Anyway, thanks!

M.


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



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