CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Calendar Sort Order

Print topic Send  topic

Author Message
steveadams617

Posts: 7
Posted: 03/15/2010, 6:21 AM

It seems the default sort order is whatever field from the database is placed first after <!-- BEGIN EventRow -->. There doesn't seem to be a second level of sorting. Changing the order the in data source has no effect.

I have a calendar with with both facility and start time to end time. The following would be an ideal sort.: facility and then start time. Anyone know how I could do it? Example:

Facility 1: 8:00 - 10:00
Facility 1: 1:00 - 3:00
Facility 3: 10:-2:00

Right now it's sorting by start time asc and faciltiy desc. Go figure... Thanks.

View profile  Send private message
andy


Posts: 183
Posted: 03/15/2010, 8:18 AM

I think you will need to base your grid on a CUSTOM SQL query

This is an example of how to do a custom sort with conditions. You will need to adapt it to your table and field structure of course:

SELECT  
tablename.fieldname1,  
tablename.fieldname2,  
(CASE when tablename.fieldnameA > 0 AND tablename.fieldnameB < 6 then 'A'  
when tablename.fieldnameA > 6 AND tablename.fieldnameB < 11 then 'B'  
when tablename.fieldnameA > 11 AND tablename.fieldnameB < 25 then 'C' END) AS Customsortorder,  
tablename.fieldname3  
FROM tablename  
ORDER BY Customsortorder Asc 

Your difficulty might arise in parsing the time field value into something that can be properly understood in the conditional expression.

For example, if your starttime and endtime fields are datetime fields yyyy-mm-dd HH:nn:ss, you need to evaluate the HH:nn:ss.

Try and get the query right first! Hope that at least puts you on the right track. ;-)
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
andy


Posts: 183
Posted: 03/15/2010, 8:30 AM

Here's how you evaluate times in SQL:

SELECT    
tablename.fieldname1,    
tablename.fieldname2,    
(CASE when TIME(tablename.fieldnameA) > "08:00:00" AND TIME(tablename.fieldnameB) < "10:00:00" then 'A'    
when TIME(tablename.fieldnameA) > "01:00:00" AND TIME(tablename.fieldnameB) < "03:00:00" then 'B'    
when TIME(tablename.fieldnameA) > "10:00:00" AND TIME(tablename.fieldnameB) < "14:00:00" then 'C' END) AS Customsortorder,    
tablename.fieldname3    
FROM tablename    
ORDER BY Customsortorder Asc 

You will probably want to use 'greater than or equal' to signs but you get the idea.
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.