Print Page | Close Window

Sorting Values And Captions

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=14372
Printed Date: 21 May 2024 at 1:40pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sorting Values And Captions
Posted By: zorknemesis
Subject: Sorting Values And Captions
Date Posted: 24 May 2009 at 2:45am
Hello!
 
We need to sort a column which contains contact-numbers.
The item/field contains constraints, which data-key corresponds with the item.value. The caption-string from the constraint displays the surname and given name from the underlying item.value.
The ReportControl displays the name of the contact correctly. But when we re-sort the column by clicking the column-caption, the column is sorted by the underlying item.value and not by the needed caption from the constraint!
 
We urgently need a workaround to this behavior! Can anyone help us?



Replies:
Posted By: Aaron
Date Posted: 30 May 2009 at 10:08am
Hi,
 
You can use SortPriority property for this kind of sorting. Assign (integer) values to SortPriority and you can sort captions properly
If I understand correct you want to show the surname (Item.Caption) and Lastname would be Item.Value, correct? Now adding items like this:
 
Set rec = wndReportControl.Records.Add()
        Set recItem = rec.AddItem("B...")
            recItem.Caption = "Aaron"
            recItem.SortPriority = AscB(recItem.Caption)
   
    Set rec = wndReportControl.Records.Add()
        Set recItem = rec.AddItem("A...")
            recItem.Caption = "SuperMario"
            recItem.SortPriority = AscB(recItem.Caption)
   
    Set rec = wndReportControl.Records.Add()
        Set recItem = rec.AddItem("N...")
            recItem.Caption = "Zork"
            recItem.SortPriority = AscB(recItem.Caption)
   
 
doesn't sort items properly (comment code with recItem.SortPriority) :
Asc:
1 > Supermario (Item.Value = A...)
2 > Aaron          (Item.Value = B...)
3 > Zork            (Item.Value = N...)
 
Desc:
1 > Zork            (Item.Value = N...)
2 > Aaron          (Item.Value = B...)
3 > Supermario (Item.Value = A...)
 
proper sort on Item.Value though
 
Now run again with code recItem.SortPriority
 
Note: If you change Item.Caption you have to change Item.SortPriority as well
 
or place code in BeforeDrawRow event: Item.SortPriority = AscB(Item.Caption)
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: zorknemesis
Date Posted: 30 May 2009 at 12:18pm
Hi Aaron,
 
thanx for the answer.
I already tried the workaround with sortpriority, and I also tried to use the AscB-Function.
But if you work with AscB, only the first letter in the caption is converted to a sortable number-value!
The result is a not properly sorted column if there are captions with the same first letter in it.
 
AND:
If you would like to set "sortpriority" programmatically for the needed recItems AFTER you have already filled the recportcontrol, and you walk through the records for setting the "sortpriority"
like this:
 
for each record in wndReportControl.records
      Set recItem = record.item(x)     
      recItem.SortPriority = AscB(recItem.Caption)
 
next record
 
then the SortPriority from those recItems which are "out of sight" (at the end of the list) are incorretly set by the recItem.Value.
btw: the recItems are having constraints!
 
Aren't there properties to set the column-sorting to the "value" OR to the "caption"???


Posted By: Aaron
Date Posted: 01 June 2009 at 4:09pm
Hi,
 
Maybe you have to approach this another way...
 
Can you upload test project?
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: malla00
Date Posted: 30 July 2009 at 6:05am
Originally posted by Aaron Aaron wrote:

Hi,
 
Maybe you have to approach this another way...
 
Can you upload test project?
 
 
 
Is there any solution to this?  I am experiencing the same problem.  I seem unable to fully sort alphabetically on a constraint column.
 


-------------
Product
------------------------
Xtreme SuitePro (ActiveX)version 12.0.0

Platform:
------------------------
Windows XP (32bit) - SP 3

Language:
------------------------
Visual Basic 6.0



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