Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - How to set Default sorted Collumn
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to set Default sorted Collumn

 Post Reply Post Reply
Author
Message
michael_veloso View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2015
Location: Perth
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael_veloso Quote  Post ReplyReply Direct Link To This Post Topic: How to set Default sorted Collumn
    Posted: 26 October 2015 at 10:39pm
Hello, First time here 
I have a question about CXTPReportControl, mfc c++

I would like to know how to set a default sort collumn.
1 side has file names and the other has modified dates, so I always want by default for the list to be sorted by the last modified date on the top.

So after all records have been added, is there a sortbycollumn(col num) ?

I cant seam to find any post or examples that show this.
Surely there must be something that allows this.


Appreciate your help.



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 (1) Thanks(1)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2016 at 4:34am
	CXTPReportColumnOrder* pColumnOrder = wndReport.GetColumns()->GetSortOrder();
pColumnOrder->Clear();

CXTPReportColumn* pSortedColumn = wndReport.GetColumns()->GetAt(3);
pSortedColumn->SetSortIncreasing(FALSE);

pColumnOrder->Add(pSortedColumn);
Back to Top
michael_veloso View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2015
Location: Perth
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael_veloso Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2016 at 9:08pm
Thank you for the reply, I found a way in the end.

//sort by column 2 descending
CXTPReportColumn* pColumn = m_GridCtrl.GetColumns()->GetAt(LETTER_TIMEDATE_COL);
if (pColumn) 
m_GridCtrl.GetColumns()->SetSortColumn(pColumn, false);

But your solutions seams more robust. As it clears any previous settings then sorts the column.
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: 20 January 2016 at 5:39am

Originally posted by michael_veloso michael_veloso wrote:

But your solutions seams more robust. As it clears any previous settings then sorts the column.

CXTPReportColumns::SetSortColumn  do the same

void CXTPReportColumns::ResetSortOrder()
{
m_pSortOrder->Clear();
}

void CXTPReportColumns::SetSortColumn(CXTPReportColumn* pColumn, BOOL bIncreasing)
{
ResetSortOrder();
m_pSortOrder->Add(pColumn, bIncreasing);
}

But in first case you can also use CXTPReportColumnOrder::InsertAt and   CXTPReportColumnOrder::RemoveAt  to add/remove several columns in sort order. And  SetSortColumn()  sets just one column.

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.