Print Page | Close Window

How to set Default sorted Collumn

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=22770
Printed Date: 16 June 2025 at 3:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to set Default sorted Collumn
Posted By: michael_veloso
Subject: How to set Default sorted Collumn
Date 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.






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


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


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




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