This is a migrated thread and some comments may be shown as answers.

Oder of Entry in Scheduler

13 Answers 307 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Praveen
Top achievements
Rank 1
Praveen asked on 06 Apr 2010, 05:04 AM
I am using a TimelineView Scheduler and order in which displays items/appointment is pretty random. I have field in the Database called priority and based on the priority, the order of the items/appointment should be displayed.

Let says I have 3 appointments scheduled on the same day for example APP1,APP2 and APP3 and their priorities are 3,2 and 1. I want the scheduler to be displayed as APP3, APP2 and APP1 but instead it displays APP1, APP2 and APP3.

Any ideas how to crack this.

Praveen

13 Answers, 1 is accepted

Sort by
0
Praveen
Top achievements
Rank 1
answered on 06 Apr 2010, 10:55 PM
Can some one throw some ideas?
0
Praveen
Top achievements
Rank 1
answered on 07 Apr 2010, 03:46 AM
How do we sort items/appointment inside TimeLine View using a custom field called "X" in the database.
0
Praveen
Top achievements
Rank 1
answered on 08 Apr 2010, 04:47 AM
I have been waiting for almost couple of days.  Can some one atleast respond some thing. This is very very urgent.
0
Peter
Telerik team
answered on 08 Apr 2010, 12:57 PM
Hi Praveen,

Please, use the AppointmentComparer property of RadScheduler as shown below:

class CustomAppointmentComparer : IComparer<Appointment>
    {
        public int Compare(Appointment first, Appointment second)
        {
            if (first == null || second == null)
            {
                throw new InvalidOperationException("Can't compare null object(s).");
            }
  
            if (first.Start < second.Start)
            {
                return -1;
            }
  
            if (first.Start > second.Start)
            {
                return 1;
            }
  
            if (first.End > second.End)
            {
                return -1;
            }
            if (first.Attributes["Priority"] != null & second.Attributes["Priority"] != null)
            {
                return String.Compare(first.Attributes["Priority"].ToString(), second.Attributes["Priority"].ToString());
            }
            return 0;
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        XmlSchedulerProvider provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/AppointmentsA.xml"), true);
        RadScheduler1.Provider = provider;
    }   
    protected void Page_Load(object sender, EventArgs e)
    {
        RadScheduler1.AppointmentComparer = new CustomAppointmentComparer(); 
    }

Attached is a demo page.

Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Praveen
Top achievements
Rank 1
answered on 08 Apr 2010, 04:22 PM
Looks like this will work when you bind XML using the <Attribute Key="Priority" />. What if I am not using XML and the Priority field comes from the database. In that case do you think CustomAttributeNames="Priority" EnableCustomAttributeEditing="true" setting will work.
0
T. Tsonev
Telerik team
answered on 08 Apr 2010, 04:49 PM
Hello Praveen,

Yes, attributes are available when binding to a data source as well. You only need to include them in your Insert/Update/Select queries.

I hope this helps.

All the best,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Praveen
Top achievements
Rank 1
answered on 09 Apr 2010, 03:57 AM
Thanks a lot. You guys rock. It works great.
0
Abhishek Sharma
Top achievements
Rank 1
answered on 26 Nov 2011, 04:56 AM
Every post I find about appointment order comes back here, but I'm not sure how I would use this to sort by start date and then description (as sometimes I have two appointments in the same time period and I'd like to sort left to right). Can you please provide an example?

thanks

Sam
0
Peter
Telerik team
answered on 28 Nov 2011, 11:57 AM
Hi Sam Smith,

The approach is still the same. Instead of a custom attribute, you should use the Description property:

return String.Compare(first.Description, second.Description);

Please, let me know if I have misunderstood your question.

All the best,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Allen
Top achievements
Rank 1
answered on 18 May 2012, 03:11 PM
Do you have VB code for this?
0
Peter
Telerik team
answered on 19 May 2012, 02:25 PM
Hello Allen,

Unfortunately, we don't have a VB version of the code, but you can use Telerik's code converter - http://converter.telerik.com/.


All the best,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Brian
Top achievements
Rank 2
answered on 29 Aug 2012, 06:03 PM
Wouldn't it be easier to retrieve the data from your datasource and add an 'order by' clause?
0
jajati
Top achievements
Rank 1
answered on 10 Jun 2015, 12:59 PM

Hi Admin

Sorting is working fine for me when I am doing the sort by 1 field (by Country). But could you please help how to sort if I have 2 fields Country, State ? First 1 want to sort by Country and then by state. Also I should be able to order by Desc or Asc

 It is bit urgent. Could you please help?

 

Tags
Scheduler
Asked by
Praveen
Top achievements
Rank 1
Answers by
Praveen
Top achievements
Rank 1
Peter
Telerik team
T. Tsonev
Telerik team
Abhishek Sharma
Top achievements
Rank 1
Allen
Top achievements
Rank 1
Brian
Top achievements
Rank 2
jajati
Top achievements
Rank 1
Share this question
or